-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (69 loc) · 3.11 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
cmake_minimum_required(VERSION 3.10)
project(Tool VERSION 0.0.1 LANGUAGES CXX)
option(BUILD_SHARED_LIBS "Build shared libs" ON)
option(TEST "test example" ON)
option(FUNCTIONS "build functions" ON)
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
#release comes with -O3 by default
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
set(CMAKE_CXX_STANDARD 11)
find_package(OpenMP REQUIRED)
find_package(ZLIB REQUIRED)
find_package(VORO REQUIRED)
#grab all file we need to compile
file(GLOB_RECURSE SOURCE src/*.cpp)
file(GLOB_RECURSE HEADERS include/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
add_library(tool ${SOURCE})
include_directories(include)
target_link_libraries(tool PRIVATE OpenMP::OpenMP_CXX ZLIB::ZLIB voro++)
install(TARGETS tool EXPORT TOOL_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT TOOL_Targets FILE TOOLConfig.cmake NAMESPACE TOOL:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TOOL)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("TOOLConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/TOOLConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TOOL)
IF(TEST)
enable_testing()
file(GLOB TestFile test/*.cpp)
# remove some test that not modified
file(GLOB NOT_test test/testQW.cpp
test/3jtest.cpp
test/testBase.cpp
test/testIO.cpp
test/testTable.cpp
test/testSh.cpp
)
list(REMOVE_ITEM TestFile ${NOT_test})
foreach(testSource ${TestFile})
string(REGEX REPLACE "^.*/([^/]*)\\.cpp$" "\\1" PROGNAME "${testSource}")
# message(${PROGNAME})
add_executable(${PROGNAME} ${testSource})
include_directories(include/)
target_link_libraries(${PROGNAME} PRIVATE tool OpenMP::OpenMP_CXX ZLIB::ZLIB voro++)
add_test(NAME ${PROGNAME} COMMAND ${PROGNAME})
# add_test(NAME ${PROGNAME} COMMAND qw46 ${CMAKE_CURRENT_SOURCE_DIR}/test/fcc.xyz)
endforeach()
# file(GLOB EXAMPLES LIST_DIRECTORIES true test/*)
endif(TEST)
# build functions
if(FUNCTIONS)
file(GLOB FunctionsFile functions/*.cpp)
# remove some test that not modified
# file(GLOB NOT_test test/testQW.cpp
# test/3jtest.cpp
# test/testBase.cpp
# test/testIO.cpp
# test/testTable.cpp
# test/testSh.cpp
# )
# list(REMOVE_ITEM FunctionsFile ${NOT_test})
foreach(functionSource ${FunctionsFile})
string(REGEX REPLACE "^.*/([^/]*)\\.cpp$" "\\1" PROGNAME "${functionSource}")
add_executable(${PROGNAME} ${functionSource})
include_directories(include/)
target_link_libraries(${PROGNAME} PRIVATE tool OpenMP::OpenMP_CXX ZLIB::ZLIB voro++)
install(TARGETS ${PROGNAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach()
endif(FUNCTIONS)