This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
65 lines (56 loc) · 2.14 KB
/
CMakeLists.txt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project("eXtendedMirror")
# Generate source files from python scripts
if (FUNC_PARAM_MAX)
set(gen_options "--function-param-max" ${FUNC_PARAM_MAX})
endif()
if (GET_N_SET_EXTR_PARAM_MAX)
set(gen_options ${gen_options} "--get-n-set-extra-param-max" ${FUNC_PARAM_MAX})
endif()
if (TEMPL_PARAM_MAX)
set(gen_options ${gen_options} "--template-param-max" ${TEMPL_PARAM_MAX})
endif()
if (TEMPL_DIR)
set(gen_options ${gen_options} "--template-dir" ${TEMPL_DIR})
endif()
find_package(PythonInterp REQUIRED)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "gen_templ.py" ${gen_options})
# Set compilation options
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(warning_flags "-Wall -Wextra -Werror")
set(std_flags "-std=c++11")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set (debug_flags "-g")
endif()
elseif ("{CMAKE_CXX_COMPIER_ID}" STREQUAL "MSVC")
set(warning_flags "/W4 /WX /EHsc")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set (debug_flags "/DEBUG")
endif()
endif()
if (NOT CONFIGURED_ONCE)
set(CMAKE_CXX_FLAGS "${warning_flags} ${std_flags} ${debug_flags}"
CACHE STRING "Flags used by the c++ compiler for all build types." FORCE)
set(CMAKE_C_FLAGS "${warning_flags} ${debug_flags}"
CACHE STRING "Flags used by the c compiler for all build types." FORCE)
endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
add_subdirectory("src/XM" "build/${CMAKE_BUILD_TYPE}")
# Installing
install(DIRECTORY include/XM DESTINATION include
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)
endif(DOXYGEN_FOUND)
# Testing
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test")
enable_testing()
add_test(all "build/${CMAKE_BUILD_TYPE}/test/tests")
set(CONFIGURED_ONCE TRUE CACHE INTERNAL
"A flag showing that CMake has configured at least once.")