-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
134 lines (109 loc) · 4.52 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
# Top-level cmake file for NuT project
# Quick start:
# Dependencies: Random123, obtain from D. E. Shaw:
# https://www.deshawresearch.com/resources_random123.html
# Ranom123 is implemented entirely in header files, so installation is minimal.
# 1. specify environment variables RANDOM123_DIR, CC, CXX. These
# should point to the root of the respective installations. For example,
# export RANDOM123_DIR=/home/me/downloads/deshaw/Random123-1.08
# 2. Under the root NuT directory, create a directory called build:
# me@superMachine:~/dev/nut$ mkdir build
# me@superMachine:~/dev/nut$ cd build
# 3. configure and build:
# me@superMachine:~/dev/nut/build$ cmake -DCMAKE_INSTALL_PREFIX=./nut -DCMAKE_BUILD_TYPE=RELEASE ..
# me@superMachine:~/dev/nut/build$ make VERBOSE=on -j 4 2>&1 | tee -a make.out
# 4. run unit tests
# me@superMachine:~/dev/nut/build$ ./test/nut_unittests
# ... tests all pass!
# Other build types: DEBUG,RELEASE,RELWITHDEBINFO
# For Doxygen, add -Dbuild_api_doc=1 to CMake command line.
# When you're tired of rebuilding Doxygen, re-run CMake with -Dbuild_api_doc=1
# To do:
# 1. incorporate build and version information into destination
# 2. incorporate CTest
# To remove all cmake added files and directories (after initial 'cmake .'):
# > make clean-cmake
# Note: This also removes all project build products as they are under dir CMakeFiles.
# This is an out of src build process (targets are not built in src dirs).
#
#
#------------------------------------------------------------
# ensure min cmake version, optional
cmake_minimum_required (VERSION 3.0)
# name the project
# languages - CXX and C are included by default
project (NuT LANGUAGES CXX)
# Enable CTest
enable_testing()
# create variable
set(NuT_COMPILE_FLAGS "-std=c++17 -g -Wall")
# append CMAKE_CXX_FLAGS w/ above variable
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NuT_COMPILE_FLAGS}")
# Do these actually do anything useful???
set_property(GLOBAL PROPERTY CXX_STANDARD 17)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON)
# ------------------------------- CMake Options -------------------------------
option(NUT_ENABLE_ASSERTIONS "Enable NuT assertions" OFF)
# --------------------------------- Random 123 ---------------------------------
if (NOT DEFINED RANDOM123_ROOT)
if (DEFINED ENV{RANDOM123_DIR})
set(RANDOM123_ROOT $ENV{RANDOM123_DIR})
message("RANDOM123_ROOT is ${RANDOM123_ROOT}")
# include_directories(
# ${RANDOM123_ROOT}/include
# )
else()
if (DEFINED ENV{RANDOM123_INCLUDES})
set(RANDOM123_ROOT $ENV{RANDOM123_INCLUDES})
message("RANDOM123_ROOT is ${RANDOM123_ROOT}")
# include_directories(
# ${RANDOM123_ROOT}/include
# )
else()
message("Warning: environment variable RANDOM123_DIR is not defined")
message("nut_unittests will not be made")
message("To make nut_unittests, set RANDOM123_DIR to top level of Random123 distribution directory (the one with docs, examples, include).")
return()
endif()
endif()
endif()
set(RANDOM123_INCLUDE_DIR ${RANDOM123_ROOT}/include)
# 2. ---------- Library ----------
add_subdirectory(lib)
# 3. ---------- Unit Tests ------------
# default behaviour is to build gtests
if (NOT DEFINED build_gtests)
set(build_gtests "yes")
endif()
# test for option "-Dbuild_gtests=yes" (-D variable is retained from prior runs)
if (${build_gtests} )
set(NuT_GTEST_DIR ${CMAKE_SOURCE_DIR}/test)
if (IS_DIRECTORY ${NuT_GTEST_DIR})
add_subdirectory(${NuT_GTEST_DIR})
else()
message("Warning: Test dir ${NuT_GTEST_DIR} not found.")
endif()
endif()
# Put this down here to catch BOOST configurizing
add_subdirectory(apps)
#----------Doxygen------------------------------
if (NOT DEFINED build_api_doc)
set(build_api_doc "no")
endif()
if (${build_api_doc} )#
find_package(Doxygen)
if (DOXYGEN_FOUND)
message("Configuring Doxygen")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
# doxygen can't make a sub-dir on the fly, so we're pre-making it here
# this should correspond to the OUTPUT_DIRECTORY in the Doxyfile.in
# grep OUTPUT_DIR Doxyfile | grep -v ^# | cut -d '=' -f 2
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxygen)
add_custom_target(doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
endif() #${build_api_doc}
# End of file