-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
127 lines (101 loc) · 2.87 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
#
# CMakeLists.txt - CMake configuration file for epanet
#
# Date Created: 9/17/2019
#
# Author: Michael E. Tryby
# US EPA - ORD/NRMRL
#
# Requirements:
# CMake - https://cmake.org/download/
#
# Build Options:
# BUILD_TESTS = ON/OFF
# BUILD_DOCS = ON/OFF
# BUILD_COVERAGE = ON/OFF
#
# Targets:
# ALL_BUILD - Builds all targets
# ZERO_CHECK - Reruns cmake
# RUN_TESTS - Builds and runs tests
# INSTALL - Stages build artifacts in install dir
# PACKAGE - Creates install package (zip file)
# doxygen - Builds toolkit docs
# clean
#
# Generic Invocation:
# cmake -E make_directory build
# cmake -G"Visual Studio 15 2017" ./build
# cmake --build ./build --config Release --target some_target
#
# More information:
# cmake docs - https://cmake.org/documentation
#
cmake_minimum_required (VERSION 3.13)
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are disabled.")
endif()
project(epanet-solver
VERSION 2.2.0
)
# Append local dir to module search path
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Sets the position independent code property for all targets
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Sets default install prefix when cmakecache is initialized for first time
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "..." FORCE)
endif()
# Define install locations (will be prepended by install prefix)
set(TOOL_DIST "bin")
set(INCLUDE_DIST "include")
set(LIBRARY_DIST "lib")
set(CONFIG_DIST "cmake")
option(BUILD_TESTS "Build component tests (requires Boost)" OFF)
option(BUILD_DOCS "Build toolkit docs (requires Doxygen)" OFF)
option(BUILD_COVERAGE "Build library for coverage" OFF)
add_subdirectory(bindings)
if(BUILD_DOCS)
add_subdirectory(doc)
endif()
add_subdirectory(src/run)
add_subdirectory(src/solver)
add_subdirectory(src/shared)
add_subdirectory(src/outfile)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Install license, authors, releaseNotes
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS"
"${CMAKE_CURRENT_SOURCE_DIR}/ReleaseNotes.md"
DESTINATION
"./"
)
# Install target import scripts so other cmake projects can use epanet libraries
install(
EXPORT
epanet2Targets
DESTINATION
"${CONFIG_DIST}"
FILE
epanet2-config.cmake
)
install(
EXPORT
epanet-outputTargets
DESTINATION
"${CONFIG_DIST}"
FILE
epanet-output-config.cmake
)
# Searches for and create install rules for vcruntime.dll, msvcp.dll, etc.
include(InstallRequiredSystemLibraries)
# Configure CPack driven installer package
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_VENDOR "US_EPA")
set(CPACK_ARCHIVE_FILE_NAME "epanet")
include(CPack)