-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
149 lines (125 loc) · 4.78 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
PROJECT( KrisLibrary )
# version (e.g. for packaging)
set(KRISLIBRARY_MAJOR_VERSION 1)
set(KRISLIBRARY_MINOR_VERSION 0)
set(KRISLIBRARY_PATCH_VERSION 0)
set(KRISLIBRARY_VERSION ${KRISLIBRARY_MAJOR_VERSION}.${KRISLIBRARY_MINOR_VERSION}.${KRISLIBRARY_PATCH_VERSION})
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules")
# COMPILER SETTINGS (default: Release) and flags
INCLUDE(CompilerSettings)
# Set output directories for libraries and executables
SET( BASE_DIR ${CMAKE_BINARY_DIR} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_DIR}/lib )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BASE_DIR}/lib )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin )
set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" ..)
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
add_subdirectory(geometry/HACD_Lib)
include_directories(${HACD_LIB_INCLUDE})
add_subdirectory(geometry/solid3)
# message(CRITICAL "SOLID INCLUDE" ${SOLID_INCLUDE_DIR})
include_directories(${SOLID_INCLUDE_DIR})
include_directories(${SOLID3_INCLUDE_DIR})
if(WIN32)
add_definitions(-DSOLID_STATIC)
endif(WIN32)
# KrisLibrary source subdirectories
SET(SUBDIRS camera geometry GLdraw graph image math math3d meshing optimization planning robotics spline statistics structs utils)
# Get all compilation files in subdirectories
file(GLOB KrisLibrary_SRCS ${PROJECT_SOURCE_DIR}/*.cpp )
foreach(s ${SUBDIRS})
file(GLOB SUBDIR_SRCS ${PROJECT_SOURCE_DIR}/${s}/*.cpp )
SET(KrisLibrary_SRCS ${KrisLibrary_SRCS} ${SUBDIR_SRCS})
SET(KrisLibrary_${s}_SRCS ${SUBDIR_SRCS})
endforeach(s)
file(GLOB PQP_SRCS ${PROJECT_SOURCE_DIR}/geometry/PQP/src/*.cpp)
SET(KrisLibrary_SRCS ${KrisLibrary_SRCS} ${PQP_SRCS})
IF(NOT WIN32)
list(REMOVE_ITEM KrisLibrary_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/image/gdi.cpp)
ENDIF(NOT WIN32)
IF(WIN32)
#output lib/Release/KrisLibrary.lib and lib/Debug/KrisLibraryd.lib
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX d)
endif()
ENDIF(WIN32)
#add all compilation files to the library
# message(critical "HACD SRC FILES" ${HACD_SRC_FILES})
# message(critical "SOLID SRC FILES" ${SOLID3_SRC_FILES})
ADD_LIBRARY( KrisLibrary STATIC ${KrisLibrary_SRCS} ${HACD_SRC_FILES} $<TARGET_OBJECTS:solid3> $<TARGET_OBJECTS:qhull>)
#Configure isinf / isnan etc using the CheckInfNan script
IF(NOT WIN32)
INCLUDE (CheckInfNan)
IF(HAS_STD_CMATH)
ADD_DEFINITIONS(-DHAS_STD_CMATH=1)
ELSE(HAS_STD_CMATH)
IF(HAS_DECL_ISINF)
ADD_DEFINITIONS(-DHAVE_DECL_ISINF=1)
ENDIF(HAS_DECL_ISINF)
IF(HAS_DECL_ISNAN)
ADD_DEFINITIONS(-DHAVE_DECL_ISNAN=1)
ENDIF(HAS_DECL_ISNAN)
IF(HAS_DECL_ISFINITE)
ADD_DEFINITIONS(-DHAVE_DECL_ISFINITE=1)
ENDIF(HAS_DECL_ISFINITE)
IF(HAS_DECL_FINITE)
ADD_DEFINITIONS(-DHAVE_DECL_FINITE=1)
ENDIF(HAS_DECL_FINITE)
IF(HAS_IEEE_COMPARISONS)
ADD_DEFINITIONS(-DHAVE_IEEE_COMPARISONS=1)
ENDIF(HAS_IEEE_COMPARISONS)
ENDIF(HAS_STD_CMATH)
ENDIF(NOT WIN32)
# Configure external libraries using the KrisLibraryDependencies script #
INCLUDE(KrisLibraryDependencies)
ADD_DEFINITIONS(${KRISLIBRARY_DEFINITIONS})
INCLUDE_DIRECTORIES(${KRISLIBRARY_INCLUDE_DIRS})
IF(NOT WIN32)
#windows has some weird stuff with link libraries
TARGET_LINK_LIBRARIES(KrisLibrary ${KRISLIBRARY_LIBRARIES})
ENDIF(NOT WIN32)
# Documentation
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf @ONLY)
ADD_CUSTOM_TARGET(docs ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating documentation (Doxygen) at location ${PROJECT_SOURCE_DIR}/doc/html/")
ENDIF(DOXYGEN_FOUND)
# uninstall target
configure_file(
"${CMAKE_MODULE_PATH}/CMakeUninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#install targets
install(TARGETS KrisLibrary
ARCHIVE
DESTINATION lib
LIBRARY
DESTINATION lib
COMPONENT libraries)
file(GLOB KrisLibrary_HDRS ${PROJECT_SOURCE_DIR}/*.h )
install(FILES ${KrisLibrary_HDRS}
DESTINATION include/KrisLibrary
COMPONENT headers)
foreach(s ${SUBDIRS})
file(GLOB SUBDIRFILES ${PROJECT_SOURCE_DIR}/${s}/*.h )
install(FILES ${SUBDIRFILES}
DESTINATION include/KrisLibrary/${s}
COMPONENT headers)
endforeach(s)
# Needs to be last statement:
INCLUDE(CPackSettings)
# Finished:
MESSAGE ("\n")
MESSAGE (STATUS "Compile KrisLibrary using: make")
MESSAGE (STATUS "Compile API-documentation using: make docs\n")
MESSAGE (STATUS "Install KrisLibrary using: make install")
MESSAGE (STATUS "Uninstall KrisLibrary using: make uninstall")