-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
134 lines (111 loc) · 4.86 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
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
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(flagser)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release
RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
find_package(Threads REQUIRED)
find_package(HDF5)
IF(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_HDF5")
ENDIF()
IF(MSVC)
set(CMAKE_CXX_RELEASE_FLAGS "${CMAKE_CXX_FLAGS} -Ox -D NDEBUG")
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -pthread -pedantic-errors")
set(CMAKE_CXX_DEBUG_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fno-omit-frame-pointer -fsanitize=memory")
set(CMAKE_CXX_RELEASE_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -D NDEBUG")
ENDIF()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_POSITION_INDEPENDANT}")
set(CMAKE_VS_PLATFORM_NAME "x64")
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
# Also add the time of the file + output file into consideration
# Add the include dir to the watch list
add_custom_command(
COMMAND ../build_custom_algorithms.sh
DEPENDS parser/math_parser.py algorithms.math
OUTPUT include/algorithms.h
COMMENT "Check for custom algorithms"
)
add_custom_target(generate_custom_algorithms DEPENDS include/algorithms.h)
add_executable(flagser src/flagser.cpp include/algorithms.h)
add_dependencies(flagser generate_custom_algorithms)
set_target_properties(flagser PROPERTIES LINKER_LANGUAGE CXX)
add_executable(flagser_retrieve_persistence src/flagser.cpp include/algorithms.h)
add_dependencies(flagser_retrieve_persistence generate_custom_algorithms)
target_compile_definitions(flagser_retrieve_persistence PRIVATE RETRIEVE_PERSISTENCE)
set_target_properties(flagser_retrieve_persistence PROPERTIES LINKER_LANGUAGE CXX)
add_executable(ripser src/ripser.cpp)
set_target_properties(ripser PROPERTIES LINKER_LANGUAGE CXX)
add_executable(flagser-count src/flagser-count.cpp)
set_target_properties(flagser-count PROPERTIES LINKER_LANGUAGE CXX)
add_executable(er src/er.cpp)
set_target_properties(er PROPERTIES LINKER_LANGUAGE CXX)
IF(NOT MSVC)
add_executable(flagser-coefficients src/flagser.cpp)
add_dependencies(flagser-coefficients generate_custom_algorithms)
target_compile_definitions(flagser-coefficients PRIVATE USE_COEFFICIENTS=1)
set_target_properties(flagser-coefficients PROPERTIES LINKER_LANGUAGE CXX)
add_executable(ripser-coefficients src/ripser.cpp)
target_compile_definitions(ripser-coefficients PRIVATE USE_COEFFICIENTS=1)
set_target_properties(ripser-coefficients PROPERTIES LINKER_LANGUAGE CXX)
ELSE()
message("On Windows, compilation with coefficients is currently not supported.")
ENDIF()
message("")
message("** CMAKE_BUILD_TYPE: \t\t\t${CMAKE_BUILD_TYPE}")
message("** CMAKE_CXX_FLAGS: \t\t\t${CMAKE_CXX_FLAGS}")
message("** CMAKE_CXX_DEBUG_FLAGS: \t\t\t${CMAKE_CXX_DEBUG_FLAGS}")
message("** CMAKE_CXX_RELEASE_FLAGS: \t\t\t${CMAKE_CXX_RELEASE_FLAGS}")
message("** CMAKE_CXX_LINK_FLAGS: \t\t${CMAKE_CXX_LINK_FLAGS}")
message("")
IF(HDF5_FOUND)
TARGET_LINK_LIBRARIES(flagser ${HDF5_LIBRARIES} pthread)
TARGET_LINK_LIBRARIES(flagser_retrieve_persistence ${HDF5_LIBRARIES} pthread)
TARGET_LINK_LIBRARIES(flagser-count ${HDF5_LIBRARIES} pthread)
TARGET_LINK_LIBRARIES(er ${HDF5_LIBRARIES} pthread)
TARGET_LINK_LIBRARIES(ripser ${HDF5_LIBRARIES} pthread)
IF(NOT MSVC)
TARGET_LINK_LIBRARIES(ripser-coefficients ${HDF5_LIBRARIES} pthread)
TARGET_LINK_LIBRARIES(flagser-coefficients ${HDF5_LIBRARIES} pthread)
ENDIF()
ENDIF()
IF(NOT MSVC)
install(TARGETS flagser flagser-coefficients flagser-count RUNTIME DESTINATION bin)
ELSE()
install(TARGETS flagser flagser-count RUNTIME DESTINATION bin)
ENDIF()
add_custom_command(
TARGET flagser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:flagser> ${CMAKE_SOURCE_DIR})
add_custom_command(
TARGET flagser_retrieve_persistence POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:flagser_retrieve_persistence> ${CMAKE_SOURCE_DIR})
add_custom_command(
TARGET flagser-count POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:flagser-count> ${CMAKE_SOURCE_DIR})
add_custom_command(
TARGET ripser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ripser> ${CMAKE_SOURCE_DIR})
add_custom_command(
TARGET er POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:er> ${CMAKE_SOURCE_DIR}/tools)
IF(NOT MSVC)
add_custom_command(
TARGET flagser-coefficients POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:flagser-coefficients> ${CMAKE_SOURCE_DIR})
add_custom_command(
TARGET ripser-coefficients POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ripser-coefficients> ${CMAKE_SOURCE_DIR})
ENDIF()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
add_subdirectory(test)
enable_testing()
endif()