-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
139 lines (115 loc) · 4.64 KB
/
Copy pathCMakeLists.txt
File metadata and controls
139 lines (115 loc) · 4.64 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_minimum_required(VERSION 3.16.0)
project(ASDP_Core_Module LANGUAGES CXX)
#-----------------------------------------------------------------------------
# Set your favorite C++ standard for compiling the internal files. The library
# will export things as extern "C" so this will not impact client programs.
# We require C++17 for the use of std::filesystem.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#-----------------------------------------------------------------------------
if(WIN32)
add_definitions(-DNOMINMAX)
# Make Windows export all symbols by default, which will create the required .lib file.
endif(WIN32)
#-----------------------------------------------------------------------------
# Local CMake Modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#-----------------------------------------------------------------------------
# Enable sorting projects within the solution on Visual Studio, to group
# Test and Example files together.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#-----------------------------------------------------------------------------
# Checking for optional and required packages
find_package(ASDP_BSP REQUIRED)
find_package(ASDP_Core_API REQUIRED)
find_package(Threads REQUIRED)
find_package(Doxygen)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
#-----------------------------------------------------------------------------
# Build options.
option(BUILD_TESTS "Build test programs" ON)
if (DOXYGEN_FOUND)
option(BUILD_DOXYGEN "Build DOxygen documentation" ON)
endif (DOXYGEN_FOUND)
if (BUILD_DOXYGEN)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
endif (BUILD_DOXYGEN)
add_definitions(-DCONFIG_FILE_PATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
#-----------------------------------------------------------------------------
# Build the helper static libraries.
set (Core_Module_HEADERS
Core_Module.h
)
set (Core_Module_SOURCES
Core_Module.cpp
)
add_library(Core_Module STATIC ${Core_Module_SOURCES} ${Core_Module_HEADERS})
target_include_directories(Core_Module PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(Core_Module PUBLIC ASDP_Core_API::ASDP_Core_API ASDP_BSP::ASDP_BSP)
#-----------------------------------------------------------------------------
# Build the Module.
set (ASDP_Core_Module_HEADERS
)
set (ASDP_Core_Module_SOURCES
ASDP_Core_Module.cpp
)
add_executable(ASDP_Core_Module ${ASDP_Core_Module_SOURCES} ${ASDP_Core_Module_HEADERS})
target_link_libraries(ASDP_Core_Module Core_Module)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(isMultiConfig)
# Multi-config (e.g., Visual Studio, Xcode)
target_compile_definitions(ASDP_Core_Module PRIVATE BUILD_TYPE="$<CONFIG>")
else()
# Single-config (e.g., Makefiles, Ninja)
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "")
target_compile_definitions(ASDP_Core_Module PRIVATE BUILD_TYPE="${CMAKE_BUILD_TYPE}")
else()
target_compile_definitions(ASDP_Core_Module PRIVATE BUILD_TYPE="Default")
endif()
endif()
include(GNUInstallDirs)
install(TARGETS ASDP_Core_Module EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION bin COMPONENT bin
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT lib
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT lib
INCLUDES DESTINATION include
PUBLIC_HEADER DESTINATION include
)
#-----------------------------------------------------------------------------
# Build tests if we've been asked to.
if(BUILD_TESTS)
enable_testing()
set (CPP_TESTS
test_BSP
)
foreach (BASE ${CPP_TESTS})
set (APP ${BASE})
add_executable (${APP} tests_cpp/${BASE}.cpp)
set_target_properties(${APP} PROPERTIES FOLDER tests/C++)
target_link_libraries(${APP} PRIVATE
ASDP_BSP::ASDP_BSP ASDP_Core_API::ASDP_Core_API
)
install(TARGETS ${APP} EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
add_test(${APP} ${APP})
endforeach (BASE)
endif(BUILD_TESTS)