2024-09-29 11:29:10 +03:00
|
|
|
cmake_minimum_required(VERSION 3.5.0)
|
2022-03-29 19:08:05 +03:00
|
|
|
|
|
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
2024-04-01 20:20:55 +03:00
|
|
|
find_program(CLACHE_PROGRAM clcache)
|
|
|
|
|
|
2022-03-29 19:08:05 +03:00
|
|
|
if(CCACHE_PROGRAM)
|
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
2024-04-01 20:20:55 +03:00
|
|
|
elseif(CLCACHE_PROGRAM)
|
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CLCACHE_PROGRAM}")
|
2022-03-29 19:08:05 +03:00
|
|
|
endif()
|
|
|
|
|
|
2024-07-09 23:47:13 +03:00
|
|
|
if(WIN32)
|
|
|
|
|
find_program(SCCACHE sccache)
|
|
|
|
|
if(SCCACHE)
|
|
|
|
|
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE})
|
|
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE})
|
|
|
|
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded)
|
|
|
|
|
cmake_policy(SET CMP0141 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-29 19:08:05 +03:00
|
|
|
project(HailoRT)
|
|
|
|
|
|
2022-06-30 17:21:15 +03:00
|
|
|
# Prevent in-tree building
|
|
|
|
|
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
|
|
|
message(FATAL_ERROR "In-source builds are not allowed.
|
|
|
|
|
Please remove the `CMakeCache.txt` file and `CMakeFiles` directory from `${CMAKE_SOURCE_DIR}`
|
|
|
|
|
In order to build, please create a new `build` directory and run `cmake ..` from there.")
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-29 19:08:05 +03:00
|
|
|
# Set compiler flags in HAILORT_COMPILE_OPTIONS
|
|
|
|
|
# TODO: Change HAILORT_COMPILE_OPTIONS to add_compile_options
|
|
|
|
|
if(WIN32)
|
|
|
|
|
# TODO: set this eventually? set(HAILORT_COMPILE_OPTIONS /Wall)
|
|
|
|
|
set(HAILORT_COMPILE_OPTIONS ${HAILORT_COMPILE_OPTIONS}
|
|
|
|
|
/W4
|
|
|
|
|
/DWIN32_LEAN_AND_MEAN
|
|
|
|
|
/DNOMINMAX # NOMINMAX is required in order to play nice with std::min/std::max (otherwise Windows.h defines it's own)
|
|
|
|
|
/D_HAILO_EXPORTING
|
|
|
|
|
/wd4201 # Anonymous union/struct
|
|
|
|
|
/wd4251 # C++ ABI with STL
|
|
|
|
|
)
|
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Disable "unsafe function" warnings
|
|
|
|
|
elseif(UNIX)
|
2022-06-30 17:21:15 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "QCC")
|
2023-06-29 15:02:42 +03:00
|
|
|
set(HAILORT_COMPILE_OPTIONS ${HAILORT_COMPILE_OPTIONS} -Wall -Wextra -Wconversion)
|
2022-03-29 19:08:05 +03:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
2023-06-29 15:02:42 +03:00
|
|
|
set(HAILORT_COMPILE_OPTIONS ${HAILORT_COMPILE_OPTIONS} -Wall -Wextra
|
2022-03-29 19:08:05 +03:00
|
|
|
# TODO: remove me warnings
|
|
|
|
|
-Wno-conversion
|
2022-09-28 22:49:02 +03:00
|
|
|
-Wno-deprecated-declarations # On c structures with deprecated attribute, clang generates implicit move ctor
|
|
|
|
|
# that causes a warning
|
2022-03-29 19:08:05 +03:00
|
|
|
-Wno-inconsistent-missing-override
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Invalid value for CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Unexpeced host, stopping build")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Enable output of compile commands during generation
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
|
|
# Add subdirectories
|
|
|
|
|
add_subdirectory(hailort)
|