-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
151 lines (132 loc) · 6.58 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
143
144
145
146
147
148
149
150
151
# C M A K E L I S T S . T X T
#
# BRL-CAD - Geometry Core
#
# Copyright (c) 1997-2011 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this file; see the file named COPYING for more
# information.
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
message("found cmake ${CMAKE_VERSION}")
PROJECT(RT3)
# Policy CMP0074 allows CMake to search
# "prefixes specified by the <PackageName>_ROOT in find_package"
# https://cmake.org/cmake/help/git-stage/policy/CMP0074.html
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif (POLICY CMP0074)
#Set path for cmake modules.
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#---------------------------------------------------------------------
# We want to check /usr/local by default, so add it
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local)
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} /usr/local/include)
#---------------------------------------------------------------------
# The location in which to install BRLCAD. Need a good Debug location
# for Windows. Only do this if CMAKE_INSTALL_PREFIX hasn't been set
# already, to try and allow parent builds (if any) some control.
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF(NOT WIN32)
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
SET(CMAKE_INSTALL_PREFIX "${RT3_SOURCE_DIR}/../rt3-install")
ELSE("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
SET(CMAKE_INSTALL_PREFIX "/usr/brlcad")
ENDIF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
ENDIF(NOT WIN32)
SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "RT3 install prefix" FORCE)
SET(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(RT3_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "RT3 install prefix")
#---------------------------------------------------------------------
# The following logic is what allows binaries to run successfully in
# the build directory AND install directory. Thanks to plplot for
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH/INSTALL_NAME_DIR to be used when installing
if (NOT APPLE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
endif(NOT APPLE)
SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH which point to
# directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#---------------------------------------------------------------------
# Output directories - this is where built library and executable
# files will be placed after building but prior to install.
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
IF(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${RT3_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
ELSE(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${RT3_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
ENDIF(WIN32)
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
IF(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${RT3_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
ENDIF(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
IF(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RT3_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
ENDIF(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
FOREACH(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
STRING(TOUPPER "${CFG_TYPE}" CFG_TYPE)
IF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
IF(WIN32)
SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${RT3_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
ELSE(WIN32)
SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${RT3_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
ENDIF(WIN32)
ENDIF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
IF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}" ${RT3_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
ENDIF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
IF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}" ${RT3_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
ENDIF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
ENDFOREACH()
# Build shared libs by default. Mark this as advanced - turning off
# ALL shared library building is unlikely to result in a working build
# and is not a typical configuration. Note that turning this option off
# will not disable libraries specifically added as SHARED.
OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
MARK_AS_ADVANCED(BUILD_SHARED_LIBS)
# Build static libs by default. Standard practice is to build and
# install both dynamic and static versions of libraries. This option
# is off by default in Debug configuration. Note that turning this
# option off will not disable libraries specifically added as STATIC
IF(CMAKE_BUILD_TYPE)
# If we're doing a debug build, don't build the static libs unless
# they're specifically asked for (i.e. there is a situation where
# the developer wants to look into the static libs specifically.
# Note that this won't turn off libs that are built ONLY as static
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND NOT MSVC)
OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF)
ENDIF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND NOT MSVC)
ELSE(CMAKE_BUILD_TYPE)
OPTION(BUILD_STATIC_LIBS "Build static libraries" ON)
ENDIF(CMAKE_BUILD_TYPE)
# We need BRL-CAD
find_package(BRLCAD REQUIRED)
# Always include the toplevel include dir
include_directories(
${RT3_SOURCE_DIR}/include
)
# Tests
ENABLE_TESTING()
# Global setup done, on to specific projects
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)