-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
85 lines (69 loc) · 2.3 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
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the source code and call cmake from there")
endif ()
cmake_minimum_required(VERSION 3.9)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
##! Project
project(magma)
##! Prerequisites CTEST
enable_testing()
##! Project options
option(MAGMA_BUILD_TESTS "Build magma tests" OFF)
option(MAGMA_BUILD_EXAMPLES "Build magma examples" OFF)
option(IDE_BUILD "Workaround for header-only libraries, put it to ON if you use CLION" OFF)
##! CMake Path
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(library)
##! Project modules
add_subdirectory(modules)
##! Project tests
if (MAGMA_BUILD_TESTS)
add_subdirectory(tests)
endif ()
##! Project examples
if (MAGMA_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()
##! Main library
add_library(magma INTERFACE)
if (NOT DEFINED ENV{CLAWS_ROOT_DEV})
message(STATUS "using insalled version of claws")
find_package(claws CONFIG REQUIRED)
else ()
message(STATUS "using development version of claws")
add_subdirectory($ENV{CLAWS_ROOT_DEV} build)
endif ()
target_link_libraries(magma INTERFACE
magma::core
)
if (NOT IDE_BUILD)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(TARGETS
magma
EXPORT magma-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/modules/magma
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp"
)
install(EXPORT magma-targets
FILE magma-targets.cmake
NAMESPACE magma::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/magma
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/magma-config.cmake.in"
"${PROJECT_BINARY_DIR}/magma-config.cmake"
INSTALL_DESTINATION lib/cmake/magma
)
install(FILES
"${PROJECT_BINARY_DIR}/magma-config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/magma)
endif ()