forked from Kiddinglife/monopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (59 loc) · 2.65 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
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_minimum_required(VERSION 3.14)
project(monopp)
include(CTest)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake/utility")
option(BUILD_MONOPP_SHARED "Build as a shared library." ON)
option(BUILD_MONOPP_MONORT "Build the monort utility library" ON)
option(BUILD_MONOPP_TESTS "Build the tests" ON)
option(BUILD_MONOPP_WITH_CODE_STYLE_CHECKS "Build with code style checks." OFF)
if(BUILD_MONOPP_TESTS)
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
message(STATUS "Enabled ${PROJECT_NAME} tests.")
set(BUILD_MONOPP_MONORT ON)
endif()
if(BUILD_MONOPP_SHARED)
set(BUILD_SHARED_LIBS ON)
endif()
if(BUILD_MONOPP_WITH_CODE_STYLE_CHECKS)
set(BUILD_WITH_CODE_STYLE_CHECKS ON)
endif()
add_subdirectory(3rdparty)
add_subdirectory(monopp)
if(BUILD_MONOPP_MONORT)
add_subdirectory(monort)
endif()
if(BUILD_MONOPP_TESTS)
add_subdirectory(tests)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
if(MINGW)
get_filename_component( Mingw_Path ${CMAKE_CXX_COMPILER} PATH )
file(GLOB MINGW_SYSTEM_RUNTIME_LIBS "${Mingw_Path}/*.dll")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${MINGW_SYSTEM_RUNTIME_LIBS})
endif()
message(STATUS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
add_custom_target(copy_compiler_dependencies ALL
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
install( PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
endif()
endif()