CMakeLists.txt 8.01 KB
Newer Older
1
cmake_minimum_required(VERSION 2.8)
Pierre Kraemer's avatar
Pierre Kraemer committed
2

3
# Thanks to Etienne Schmitt for CMakeLists modifications
Pierre Kraemer's avatar
Pierre Kraemer committed
4

5
project(CGoGN)
untereiner's avatar
untereiner committed
6

7
SET ( CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR} )
8
SET ( CGoGN_SRC_DIR ${CMAKE_SOURCE_DIR}/CGoGN)
9
SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ )
Sylvain Thery's avatar
Sylvain Thery committed
10

11
INCLUDE(${CGoGN_ROOT_DIR}/cmake_modules/functions.cmake)
Sylvain Thery's avatar
Sylvain Thery committed
12

13 14


15 16 17
#
# Available options
#
18 19 20
SET ( CGoGN_WITH_ASSIMP OFF CACHE BOOL "build CGoGN with Assimp" )
SET ( CGoGN_WITH_ZINRI OFF CACHE BOOL "build CGoGN with Zinri lib" )
SET ( CGoGN_WITH_QT ON CACHE BOOL "build CGoGN with Qt lib" )
21
SET ( DESIRED_QT_VERSION "4" CACHE STRING "4: QT4/ 5 not yet implemented" )
Sylvain Thery's avatar
Sylvain Thery committed
22
SET ( CGoGN_WITH_GLEWMX OFF CACHE BOOL "use multi-contex GLEW (for VRJuggler)" )
23 24 25 26 27 28 29 30 31
SET ( CGoGN_USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not work on mac)" )

SET ( CGoGN_COMPILE_EXAMPLES OFF CACHE BOOL "compile examples" )
SET ( CGoGN_COMPILE_TUTOS OFF CACHE BOOL "compile tutorials" )
SET ( CGoGN_COMPILE_TESTS OFF CACHE BOOL "compile tests" )
SET ( CGoGN_COMPILE_BENCHES OFF CACHE BOOL "compile benches" )
SET ( CGoGN_COMPILE_SANDBOX OFF CACHE BOOL "compile all in sandbox" )
SET ( CGoGN_ASSERT_ACTIVED OFF CACHE BOOL "assertion activated")
SET ( CGoGN_ONELIB OFF CACHE BOOL "build CGoGN in one lib" )
32 33 34 35
IF (WIN32)
	SET ( BUILD_SHARED_LIBS OFF CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
	SET ( CMAKE_CONFIGURATION_TYPES Release Debug)
	SET ( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
36
	SET ( CGoGN_WITH_QTCREATOR OFF CACHE BOOL "use QtCreator to compile" )
37 38 39
ELSE (WIN32)
	SET ( BUILD_SHARED_LIBS ON CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
ENDIF ()
40

41 42 43 44 45 46

checkCpp11Support()
setBuildType()


SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/)
47
IF(WIN32 AND (NOT CGoGN_WITH_QTCREATOR))
48 49 50
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib)
ELSE()
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
Sylvain Thery's avatar
Sylvain Thery committed
51 52
ENDIF()

53 54 55
#
# External Libraries (not included a third party libraries)
#
Sylvain Thery's avatar
Sylvain Thery committed
56 57 58 59 60

IF(WIN32)
	SET ( CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies" )
ENDIF(WIN32)

61 62 63
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
64
IF (CGoGN_WITH_QT)
65 66 67 68 69
	SET(QT_USE_QTCORE TRUE)
	SET(QT_USE_QTOPENGL TRUE)
	SET(QT_USE_QTSVG TRUE)
	SET(QT_USE_QTXML TRUE )
	FIND_PACKAGE(Qt REQUIRED)
70
ELSE ()
71
	FIND_PACKAGE(DevIL REQUIRED)
72
ENDIF()
73 74
IF (NOT WIN32)
	FIND_PACKAGE(SuiteSparse REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
75 76 77 78 79 80 81 82
ELSE()
	set(SuiteSparse_SUITESPARSECONFIG_INCLUDE_DIR  ${CGoGN_ROOT_DIR}/windows_dependencies/include)
	set(SuiteSparse_USE_LAPACK_BLAS ON)
	find_package(SuiteSparse QUIET NO_MODULE)
	if(NOT SuiteSparse_FOUND)
        set(SuiteSparse_VERBOSE ON)
        find_package(SuiteSparse REQUIRED) # 2nd: Use FindSuiteSparse.cmake module
	endif()
83
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
84

85 86 87 88 89 90 91 92 93 94 95 96
#
# COMPILER FLAGS
#
IF(NOT WIN32)
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
	# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
	IF(CMAKE_COMPILER_IS_GNUCXX)
		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs")
	ENDIF()
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
97

98 99
if(APPLE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
Sylvain Thery's avatar
Sylvain Thery committed
100 101 102
endif()


103 104 105 106
#
# COMPILE DEFINITIONS
#
add_definitions("-DCGOGN_ASSERT_BOOL=${ASSERT_ACTIVED}")
107

108
IF(CGoGN_USE_OGL_CORE_PROFILE)
Sylvain Thery's avatar
Sylvain Thery committed
109
        add_definitions("-DCGoGN_USE_OGL_CORE_PROFILE=1")
Sylvain Thery's avatar
Sylvain Thery committed
110 111
ENDIF()

112
add_definitions("-DGLM_FORCE_RADIANS")
Sylvain Thery's avatar
Sylvain Thery committed
113

114
add_definitions("-DSHADERPATH=\"${CGoGN_ROOT_DIR}/lib/Shaders/\"")
Sylvain Thery's avatar
Sylvain Thery committed
115

116
IF (CGoGN_WITH_ASSIMP)
117
	add_definitions(-DWITH_ASSIMP)	
118
ENDIF ()
119

120
IF (CGoGN_WITH_ZINRI)
121
	add_definitions(-DWITH_ZINRI)
122
ENDIF ()
123

124
IF (CGoGN_WITH_GLEWMX)
125
	ADD_DEFINITIONS(-DGLEW_MX)
126
ENDIF ()
127

Sylvain Thery's avatar
Sylvain Thery committed
128

129 130 131 132
#
#	ThirdParty
#
#add_subdirectory(ThirdParty)
133

134
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/include)
Sylvain Thery's avatar
Sylvain Thery committed
135

136 137 138 139 140 141 142 143
ADD_SUBDIRECTORY(ThirdParty/Tools)

ADD_SUBDIRECTORY(ThirdParty/OpenNL)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/OpenNL/src)

ADD_SUBDIRECTORY(ThirdParty/tetgen)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/tetgen)

144
IF (CGoGN_WITH_ZINRI)
145 146
	ADD_SUBDIRECTORY(ThirdParty/Zinri)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/Zinri)
147
ENDIF()
148

149
IF (CGoGN_WITH_ASSIMP)
150 151
	ADD_SUBDIRECTORY(ThirdParty/Assimp)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include/)
152
ENDIF ()
Sylvain Thery's avatar
Sylvain Thery committed
153

154 155 156
ADD_SUBDIRECTORY(ThirdParty/TinyXml2)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2)

Sylvain Thery's avatar
Sylvain Thery committed
157
IF (CGoGN_WITH_QT AND (NOT WIN32))
158 159 160
	ADD_SUBDIRECTORY(ThirdParty/libQGLViewer/QGLViewer)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/libQGLViewer/)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
161

162 163 164 165
IF (NOT WIN32)
	ADD_SUBDIRECTORY(ThirdParty/libuuid)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/libuuid)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
166 167


168

169
IF (CGoGN_ONELIB)
170
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "1" )
171
ELSE ()
172
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "0" )
173
ENDIF ()
174

175
IF (CGoGN_WITH_GLEWMX)
176
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "1" )
177
ELSE ()
178
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "0" )
179
ENDIF ()
180

181 182 183 184 185 186
IF (CGoGN_USE_OGL_CORE_PROFILE)
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_coreprofile.h "1" )
ELSE ()
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_coreprofile.h "0" )
ENDIF ()

187

188 189 190 191 192
#
# INCLUDES AND LIBS
#
SET (CGoGN_EXT_INCLUDES)
SET (CGoGN_EXT_LIBS)
193
IF (CGoGN_WITH_QT)
194 195 196 197 198
		INCLUDE(${QT_USE_FILE})
        ADD_DEFINITIONS(-DWITH_QT)
        ADD_DEFINITIONS(${QT_DEFINITIONS})
        LIST(APPEND CGoGN_EXT_INCLUDES ${QT_INCLUDE_DIR})
        LIST(APPEND CGoGN_EXT_LIBS QGLViewer ${QT_LIBRARIES})
199
ELSE ()
200 201
	 LIST(APPEND CGoGN_EXT_INCLUDES ${IL_INCLUDE_DIR})
	 LIST(APPEND CGoGN_EXT_LIBS ${IL_LIBRARIES})
202
ENDIF ()
203

Sylvain Thery's avatar
Sylvain Thery committed
204
# define includes of external libs 
205 206
LIST(INSERT CGoGN_EXT_INCLUDES 0
    ${CGoGN_ROOT_DIR}/ThirdParty/include
Sylvain Thery's avatar
Sylvain Thery committed
207 208 209
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
Sylvain Thery's avatar
Sylvain Thery committed
210
	${SuiteSparse_INCLUDE_DIRS}
211
)
Sylvain Thery's avatar
Sylvain Thery committed
212 213

# define libs for external libs
214
IF (CGoGN_WITH_ASSIMP)
215
	LIST(APPEND CGoGN_EXT_LIBS assimp)
216
ENDIF ()
217

218
IF (CGoGN_WITH_ZINRI)
219
	LIST(APPEND CGoGN_EXT_LIBS Zinri)
220
ENDIF ()
221 222 223 224

LIST(APPEND CGoGN_EXT_LIBS
    nl
    tinyxml2
Sylvain Thery's avatar
Sylvain Thery committed
225 226 227
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
Sylvain Thery's avatar
Sylvain Thery committed
228
	${SuiteSparse_LIBRARIES}
229
)
230

Sylvain Thery's avatar
Sylvain Thery committed
231 232 233
IF(NOT WIN32)
	LIST(APPEND CGoGN_EXT_LIBS pthread) #for c++11 thread
ENDIF()
234

235
include_directories( 
236
	${CGoGN_SRC_DIR}/include
237
	${CGoGN_EXT_INCLUDES} )
Sylvain Thery's avatar
Sylvain Thery committed
238 239


240
add_subdirectory(${CGoGN_SRC_DIR} CGoGN)
Sylvain Thery's avatar
Sylvain Thery committed
241 242

add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
Sylvain Thery's avatar
Sylvain Thery committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301


# 
# Add custom clean targets for cleaning without cleaning dependencies
#
if (WIN32)
	add_custom_target(clean_cgogn 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn PRE_BUILD 
			COMMAND del /q CCoGN
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning CGoGN libs")

	add_custom_target(clean_apps 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_apps PRE_BUILD 
			COMMAND del /q Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")

	add_custom_target(clean_cgogn_apps 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn_apps PRE_BUILD 
			COMMAND del /q CGoGN
			COMMAND del /q Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")

ELSE()

	add_custom_target(clean_cgogn 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn PRE_BUILD 
			COMMAND rm -rf CGoGN
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning CGoGN libs")

	add_custom_target(clean_apps 
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_apps PRE_BUILD 
			COMMAND rm -rf Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")

	add_custom_target(clean_cgogn_apps 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn_apps PRE_BUILD 
			COMMAND rm -rf CGoGN
			COMMAND rm -rf Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")

ENDIF()