forked from cburstedde/libsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (66 loc) · 2.53 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
cmake_minimum_required(VERSION 3.14...3.25)
include(cmake/git.cmake)
project(SC
LANGUAGES C
HOMEPAGE_URL https://www.p4est.org/
DESCRIPTION "The SC library supports parallel scientific applications."
VERSION ${PROJECT_VERSION})
enable_testing()
include(cmake/options.cmake)
message(STATUS "libsc ${PROJECT_VERSION} "
"install prefix: ${CMAKE_INSTALL_PREFIX}")
# options.cmake before config.cmake to determine user intent
include(cmake/config.cmake)
# compilers.cmake must be AFTER find_package() calls in config.cmake in general
include(cmake/compilers.cmake)
# --- iniparser
add_library(iniparser OBJECT
iniparser/inistring.c iniparser/dictionary.c iniparser/iniparser.c)
target_include_directories(iniparser PRIVATE iniparser src ${PROJECT_BINARY_DIR}/include)
target_link_libraries(iniparser PRIVATE $<$<BOOL:${SC_ENABLE_MPI}>:MPI::MPI_C>)
# --- libb64
add_library(libb64 OBJECT libb64/cencode.c libb64/cdecode.c)
target_include_directories(libb64 PRIVATE libb64)
# --- sc
add_library(sc $<TARGET_OBJECTS:iniparser> $<TARGET_OBJECTS:libb64>)
target_compile_features(sc PRIVATE c_std_99)
set_property(TARGET sc PROPERTY EXPORT_NAME SC)
set_property(TARGET sc PROPERTY VERSION ${PROJECT_VERSION})
target_include_directories(sc
PRIVATE iniparser libb64
PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/sc_builtin>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(sc PUBLIC
$<$<BOOL:${SC_ENABLE_MPI}>:MPI::MPI_C>
$<$<BOOL:${SC_HAVE_ZLIB}>:ZLIB::ZLIB>
$<$<BOOL:${SC_NEED_M}>:m>
)
# imported target, for use from FetchContent
add_library(SC::SC INTERFACE IMPORTED GLOBAL)
target_link_libraries(SC::SC INTERFACE sc)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ ${PROJECT_SOURCE_DIR}/src/sc_builtin/ ${PROJECT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(TARGETS sc EXPORT ${PROJECT_NAME}-targets)
add_subdirectory(src)
add_subdirectory(example)
if(BUILD_TESTING)
add_subdirectory(test)
endif(BUILD_TESTING)
# --- packaging
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSC.cmake
DESTINATION cmake)
include(cmake/pkgconf.cmake)
include(cmake/install.cmake)
include(FeatureSummary)
add_feature_info(MPI mpi "MPI features of libsc")
add_feature_info(OpenMP openmp "OpenMP features of libsc")
add_feature_info(ZLIB zlib "ZLIB features of libsc")
add_feature_info(shared BUILD_SHARED_LIBS "shared libsc library")
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)