-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
111 lines (91 loc) · 3.8 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
cmake_minimum_required (VERSION 2.8.7)
############################################################
project (ASDF)
include(GNUInstallDirs)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Werror")
set(CMAKE_C_FLAGS_RELWITHDEBINFO
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -Wall -Werror")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wall -Werror")
############################################################
### Dependencies ###
############################################################
find_package(HDF5 1.8.0 REQUIRED)
include_directories(${HDF5_INCLUDE_DIR})
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
option (TEST "Run unit tests" OFF)
############################################################
### Setup directory structure ###
############################################################
include_directories (./inc)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) # .so
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) # .a
set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
############################################################
### ASDF library ###
############################################################
add_library (asdf
${SRC_DIR}/ASDF_init.c
${SRC_DIR}/ASDF_read.c
${SRC_DIR}/ASDF_write.c
${SRC_DIR}/gen_provenance_id.cpp
${SRC_DIR}/gen_provenance_entity.cpp
${SRC_DIR}/gen_sf_provenance.cpp
${SRC_DIR}/ASDF_f.c)
target_link_libraries(asdf
${HDF5_LIBRARIES} ${MPI_C_LIBRARIES})
install(TARGETS asdf
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
file(GLOB inc_files inc/*.h)
install(FILES ${inc_files}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (${CMAKE_VERSION} VERSION_GREATER 3.1)
set_property(TARGET asdf PROPERTY CXX_STANDARD 11)
else()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(FATAL_ERROR
"The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. "
"Please use a different C++ compiler.")
endif()
endif()
############################################################
### Documentation Generation ###
############################################################
# See: https://www.tty1.net/blog/2014/cmake-doxygen_en.html
find_package(Doxygen)
option (BUILD_DOCUMENTATION
"Create and install the HTML based API documentation (requires Doxygen)"
${DOXYGEN_FOUND})
if (BUILD_DOCUMENTATION)
if (NOT DOXYGEN_FOUND)
message (FATAL_ERROR "Doxygen is needed to build the documentation.")
endif ()
set (doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set (doxyfile ${CMAKE_BINARY_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target (doc
command ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()
install(FILES README.md
DESTINATION ${CMAKE_INSTALL_DOCDIR})
############################################################
if (TEST)
include(CTest) # enable_testing() is not enough to 'make test'
add_subdirectory(test)
endif()
add_subdirectory(examples)