-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
88 lines (71 loc) · 2.73 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
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 3.12)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
##
# Function that generates source groups
##
function(GenerateSourceGoups Sources)
foreach(Source ${Sources})
get_filename_component(SourcePath "${Source}" PATH)
if (WIN32)
string(REPLACE "/" "\\" SourcePath "${SourcePath}")
endif()
source_group("${SourcePath}" FILES "${Source}")
endforeach()
endfunction()
##
# Start
##
project(PolyPlugin VERSION "1.0.0")
include(GNUInstallDirs)
configure_file(
"${PROJECT_SOURCE_DIR}/config/CmakeConfig.hpp.in"
"${PROJECT_BINARY_DIR}/config/CmakeConfig.hpp"
)
include_directories("${PROJECT_BINARY_DIR}/config")
set(POLY_PLUGIN_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(DIST_DIR "${POLY_PLUGIN_ROOT_DIR}/Dist")
set(COMMON_BUILD_DIR "${POLY_PLUGIN_ROOT_DIR}/CommonBuild")
# Output dirs
if (WIN32)
set(FULL_DIST_DIR "${DIST_DIR}") # Config name is added autmatically on windows
else()
set(FULL_DIST_DIR "${DIST_DIR}/${BUILD_CONFIG_NAME}")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${FULL_DIST_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${FULL_DIST_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${FULL_DIST_DIR})
# C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(POLYPLUGIN_TARGET PolyPlugin)
set(CALCULATOR_PLUGIN_API_TARGET CalculatorPluginAPI)
set(CALCULATOR_PLUGIN_TARGET CalculatorPlugin)
set(TEST_APP_TARGET TestApp)
add_subdirectory(PolyPlugin)
add_subdirectory(Test/CalculatorPluginAPI)
add_subdirectory(Test/CalculatorPlugin)
add_subdirectory(Test/TestApp)
#################################################
# installation instructions
#################################################
install(TARGETS ${POLYPLUGIN_TARGET}
EXPORT ${POLYPLUGIN_TARGET}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${POLYPLUGIN_TARGET}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${POLYPLUGIN_TARGET}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${POLYPLUGIN_TARGET}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${POLYPLUGIN_TARGET}/cmake)
install(EXPORT ${POLYPLUGIN_TARGET}_Targets
FILE ${POLYPLUGIN_TARGET}Targets.cmake
NAMESPACE ${POLYPLUGIN_TARGET}::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${POLYPLUGIN_TARGET}/cmake)
install(FILES "${PROJECT_BINARY_DIR}/${POLYPLUGIN_TARGET}Config.cmake"
"${PROJECT_BINARY_DIR}/${POLYPLUGIN_TARGET}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${POLYPLUGIN_TARGET}/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/PolyPlugin/src/pp DESTINATION include)