-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
142 lines (116 loc) · 3.94 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
135
136
137
138
139
140
141
142
cmake_minimum_required(VERSION 2.6)
include(CheckIncludeFile)
project( hydrotrend )
option (WITH_PYTHON_BINDINGS "Build Python bindings" OFF)
option (WITH_CTEST "Use CTest to build tests" OFF)
set (BUILD_SHARED_LIBS ON)
set (HYDROTREND_VERSION 3.1)
set (HYDROTREND_EXE run_hydrotrend)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/hydrotrend.pc.cmake ${CMAKE_CURRENT_SOURCE_DIR}/hydrotrend.pc )
if (WITH_CTEST)
include (CTest)
ENABLE_TESTING()
add_test (HYDROTREND_VERSION ${HYDROTREND_EXE} --version)
add_test (HYDROTREND_HELP ${HYDROTREND_EXE} --help)
add_test (HYDROTREND_TEST_WITHOUT_ARGS
${CMAKE_CURRENT_BINARY_DIR}/data/hydrotrend_test_without_args.sh)
#add_test (HYDROTREND_TEST_WITH_ARGS
# ${CMAKE_CURRENT_BINARY_DIR}/data/hydrotrend_test_with_args.sh)
endif (WITH_CTEST)
add_subdirectory( data )
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/hydrotrend.pc.cmake
${CMAKE_CURRENT_SOURCE_DIR}/hydrotrend.pc )
########### libhydrotrend ###############
check_include_file(getopt.h WITH_GETOPT)
check_include_file(unistd.h WITH_UNISTD)
find_library(LIB_M m)
if (WITH_GETOPT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_GETOPT")
endif (WITH_GETOPT)
if (WITH_UNISTD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_UNISTD")
endif (WITH_UNISTD)
find_library(LIB_M m)
set(hydrotrend_lib_SRCS
bmi_hydrotrend.c
hydrotrend_irf.c
hydroalloc_mem.c
hydrocalqsnew.c
hydrocheckinput.c
hydroclimate.c
hydrotrend_cli.c
hydroexpdist.c
hydrofree_mem.c
hydroglacial.c
hydrohypsom.c
hydroinputalloc.c
hydromaxevents.c
hydroopenfiles.c
hydrooutlet.c
hydrooutput.c
hydroprintannual.c
hydroprintstat.c
hydrorain.c
hydroran2.c
hydroran2sediment.c
hydrorandom.c
hydrorandomsediment.c
hydroreadclimate.c
hydroreadevaporation.c
hydroreadearthquake.c
hydroreadhypsom.c
hydroreadinput.c
hydrosecurityinputcheck.c
hydrosedload.c
hydrosetgeoparams.c
hydrosetglobalpar.c
hydrosetparams.c
hydroshoulder.c
hydroshuffle.c
hydrosnow.c
hydrosumflow.c
hydroswap.c
hydroweather.c)
########### BMI ###########
add_library(bmi_hydrotrend ${hydrotrend_lib_SRCS})
add_library(bmi_hydrotrend-static STATIC ${hydrotrend_lib_SRCS} )
install(TARGETS bmi_hydrotrend DESTINATION lib)
install(TARGETS bmi_hydrotrend-static DESTINATION lib)
install(FILES bmi.h bmi_hydrotrend.h DESTINATION include/hydrotrend)
########### hydrotrend main program ###############
set(hydrotrend_SRCS hydrotrend_main.c)
add_executable(run_hydrotrend ${hydrotrend_SRCS})
if (LIB_M)
target_link_libraries(run_hydrotrend bmi_hydrotrend-static m)
elseif (NOT LIB_M)
target_link_libraries(run_hydrotrend bmi_hydrotrend-static)
endif (LIB_M)
install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_hydrotrend${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION bin
RENAME hydrotrend${CMAKE_EXECUTABLE_SUFFIX}
COMPONENT hydrotrend
)
########### Install files ###############
install(FILES hydrotrend.pc DESTINATION lib/pkgconfig COMPONENT hydrotrend)
########### Configuration Information ###############
if ( CMAKE_BUILD_TYPE MATCHES Release )
set( cflags ${CMAKE_C_FLAGS_RELEASE} )
elseif ( CMAKE_BUILD_TYPE MATCHES Debug )
set( cflags ${CMAKE_C_FLAGS_DEBUG} )
else ( )
set( cflags ${CMAKE_C_FLAGS} )
endif ( CMAKE_BUILD_TYPE MATCHES Release )
message("------------------------------------------------------------------------")
message("Configuration:")
message("")
message(" Source code location: ${CMAKE_SOURCE_DIR}")
message(" Build type: ${CMAKE_BUILD_TYPE}")
message(" Compiler: ${CMAKE_C_COMPILER}")
message(" Compiler flags: ${cflags}")
message(" Host System Type: ${CMAKE_HOST_SYSTEM}")
message(" Installation architecture: ${CMAKE_SYSTEM}")
message(" Install path: ${CMAKE_INSTALL_PREFIX}")
message(" With doxygen: ${DOXYGEN}")
message("")
message("------------------------------------------------------------------------")