forked from sony/nmos-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNmosCppCommon.cmake
More file actions
50 lines (41 loc) · 1.71 KB
/
NmosCppCommon.cmake
File metadata and controls
50 lines (41 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
set(NMOS_CPP_USE_CONAN ON CACHE BOOL "Use Conan to acquire dependencies")
mark_as_advanced(FORCE NMOS_CPP_USE_CONAN)
if(NMOS_CPP_USE_CONAN)
include(cmake/NmosCppConan.cmake)
endif()
include(GNUInstallDirs)
# if both variables aren't empty strings, join them
string(JOIN "/" NMOS_CPP_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} ${NMOS_CPP_INCLUDE_PREFIX})
set(NMOS_CPP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
set(NMOS_CPP_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
if(WIN32)
string(APPEND NMOS_CPP_INSTALL_LIBDIR "/$<IF:$<CONFIG:Debug>,Debug,Release>")
string(APPEND NMOS_CPP_INSTALL_BINDIR "/$<IF:$<CONFIG:Debug>,Debug,Release>")
endif()
# enable C++
enable_language(CXX)
# check C++11 or higher
if(CMAKE_CXX_STANDARD STREQUAL "98")
message(FATAL_ERROR "CMAKE_CXX_STANDARD must be 11 or higher; C++98 is not supported")
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(NMOS_CPP_BUILD_TESTS AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# note: to see the output of any failed tests, set CTEST_OUTPUT_ON_FAILURE=1 in the environment
# and also remember that CMake doesn't add dependencies to the "test" (or "RUN_TESTS") target
# so after changing code under test, it is important to "make all" (or build "ALL_BUILD")
enable_testing()
endif()
# location of additional CMake modules
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/third_party/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake
)
# guard against in-source builds and bad build-type strings
include(safeguards)
# common compiler flags and warnings
include(cmake/NmosCppCompileSettings.cmake)