Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

CMakeLists.txt 10.1 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1
cmake_minimum_required(VERSION 2.8)
Pierre Kraemer's avatar
Pierre Kraemer committed
2
3
4

project(CGoGN)

5
#SET ( CMAKE_VERBOSE_MAKEFILE 1 )
untereiner's avatar
untereiner committed
6

7
SET ( CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR} )
Pierre Kraemer's avatar
Pierre Kraemer committed
8

9
SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ )
Sylvain Thery's avatar
Sylvain Thery committed
10

Sylvain Thery's avatar
Sylvain Thery committed
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# ====== Check GCC VERSION FOR C++11 ======
if(CMAKE_COMPILER_IS_GNUCXX)
	execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
	if (GCC_VERSION VERSION_LESS 4.8)
		message(FATAL_ERROR "Full support of C++11 needed. Therefore a gcc/g++ compiler with a version at least 4.8 is needed.")
	endif()
endif()

# ====== Check CLANG VERSION FOR C++11 ======
if (APPLE)
	execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
	if (CLANG_VERSION VERSION_LESS 3.1)
		message(FATAL_ERROR "Full support of C++11 needed. Therefore a clang compiler with a version at least 3.1 is needed !!")
	endif()
endif()

# ====== Check MSVC VERSION FOR C++11 ======
if(WIN32)
	if(MSVC_VERSION LESS 1800)
		message(FATAL_ERROR "Full support of C++11 needed. Therefore a microsoft compiler with a version at least 12 is needed.")
	endif()
endif()

Sylvain Thery's avatar
Sylvain Thery committed
35
36
37
38
39
40
41
42
43

IF (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug|Release"))
	IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug|(.*)debug|(.*)DEBUG")
		SET(CMAKE_BUILD_TYPE "Debug")
	ELSE()
		SET(CMAKE_BUILD_TYPE "Release")
	ENDIF()
ENDIF()

Sylvain Thery's avatar
Sylvain Thery committed
44
# for shared or not shared
45
46
SET ( BUILD_SHARED_LIBS OFF CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )

Sylvain Thery's avatar
Sylvain Thery committed
47
48
#IF(EXISTS "${CGoGN_ROOT_DIR}/ThirdParty/include/Assimp")
IF(EXISTS "${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE}/*assimp*")
Sylvain Thery's avatar
Sylvain Thery committed
49
50
51
52
53
54
55
56
57
58
59
	SET ( WITH_ASSIMP ON CACHE BOOL "build CGoGN with Assimp" )
ELSE()
	SET ( WITH_ASSIMP OFF CACHE BOOL "build CGoGN with Assimp" )
ENDIF()

IF(EXISTS "${CGoGN_ROOT_DIR}/ThirdParty/include/Zinri")
	SET ( WITH_ZINRI ON CACHE BOOL "build CGoGN with Zinri lib" )
ELSE()
	SET ( WITH_ZINRI OFF CACHE BOOL "build CGoGN with Zinri lib" )
ENDIF()

60
SET ( WITH_QT ON CACHE BOOL "build CGoGN with Qt lib" )
Thery Sylvain's avatar
Thery Sylvain committed
61
SET ( DESIRED_QT_VERSION "4" CACHE STRING "4: QT4/ 5 not yet implemented" )
Sylvain Thery's avatar
Sylvain Thery committed
62

Sylvain Thery's avatar
Sylvain Thery committed
63
64
65
66
67
SET ( COMPILE_EXAMPLES ON CACHE BOOL "compile examples" )
SET ( COMPILE_TUTOS ON CACHE BOOL "compile tutorials" )
SET ( COMPILE_TESTS ON CACHE BOOL "compile tests" )
SET ( COMPILE_BENCHES ON CACHE BOOL "compile benches" )
SET ( COMPILE_SANDBOX ON CACHE BOOL "compile all in sandbox" )
68
69


70
#create one big lib
71
72
73
SET ( ONELIB OFF CACHE BOOL "build CGoGN in one lib" )

SET ( WITH_GLEWMX OFF CACHE BOOL "use multi-contex GLEW" )
74
SET( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not work on mac)" )
75

Sylvain Thery's avatar
Sylvain Thery committed
76
77

IF(WIN32)
78
	SET ( CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies" )
Sylvain Thery's avatar
Sylvain Thery committed
79
ENDIF(WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
80

thery's avatar
thery committed
81
find_package(OpenGL REQUIRED)
82
find_package(Boost COMPONENTS regex REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
83
84
find_package(ZLIB REQUIRED)
find_package(GLEW REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
85

Sylvain Thery's avatar
Sylvain Thery committed
86
# MESSAGE HERE FOR MORE EASY USER READING
Sylvain Thery's avatar
Sylvain Thery committed
87
MESSAGE("Building type = " ${CMAKE_BUILD_TYPE} " (for change with cmake use -DCMAKE_BUILD_TYPE=Release|Debug)" )
Sylvain Thery's avatar
Sylvain Thery committed
88
89


90
91
92
93
94
95
IF (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
ELSE (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=false)
ENDIF (DEFINED ASSERTON)

96
97
98
99
100
101
IF (ONELIB)
	file(WRITE ${CGoGN_ROOT_DIR}/include/cgogn_onelib.h "1" )
ELSE (ONELIB)
	file(WRITE ${CGoGN_ROOT_DIR}/include/cgogn_onelib.h "0" )
ENDIF (ONELIB)

102
103
104
105
106
107
108
IF (WITH_GLEWMX)
	file(WRITE ${CGoGN_ROOT_DIR}/include/cgogn_gmx.h "1" )
ELSE (WITH_GLEWMX)
	file(WRITE ${CGoGN_ROOT_DIR}/include/cgogn_gmx.h "0" )
ENDIF (WITH_GLEWMX)


109
110
111
112
IF(USE_OGL_CORE_PROFILE)
	add_definitions(-DUSE_OGL_CORE_PROFILE=1)
ENDIF()

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

115
116
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")

Sylvain Thery's avatar
Sylvain Thery committed
117
# define includes of external libs 
118
119
SET (CGoGN_EXT_INCLUDES
	${CGoGN_ROOT_DIR}/ThirdParty/include
Sylvain Thery's avatar
Sylvain Thery committed
120
121
122
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
123
124
	${Boost_INCLUDE_DIRS}
)
Sylvain Thery's avatar
Sylvain Thery committed
125
126

# define libs for external libs
127
SET (CGoGN_EXT_LIBS
128
    nl
Sylvain Thery's avatar
Sylvain Thery committed
129
130
131
132
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
	${Boost_REGEX_LIBRARY}
133
	tinyxml2
134
)
135

136
137
138
139
140
141
142
143
144
IF(WIN32)
	SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse)
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} 
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/suitesparse.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/metis.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/liblapack.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/libblas.lib		)
ELSE(WIN32)
	find_package(SuiteSparse REQUIRED)
unknown's avatar
unknown committed
145
	SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${SUITESPARSE_INCLUDE_DIRS})
146
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} ${SUITESPARSE_LIBRARIES} pthread)
147
148
ENDIF(WIN32)

unknown's avatar
unknown committed
149

150
#optionnal libs
Sylvain Thery's avatar
Sylvain Thery committed
151
IF (WITH_ASSIMP)
152
	add_definitions(-DWITH_ASSIMP)	
153
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} assimp)
Sylvain Thery's avatar
Sylvain Thery committed
154
#	INSTALL (DIRECTORY ThirdParty/Assimp/include  DESTINATION .)
Sylvain Thery's avatar
Sylvain Thery committed
155
156
ENDIF (WITH_ASSIMP)

157
158
159
IF (WITH_ZINRI)
	add_definitions(-DWITH_ZINRI)
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} Zinri)
Sylvain Thery's avatar
Sylvain Thery committed
160
#	INSTALL (DIRECTORY ThirdParty/Zinri/ DESTINATION include FILES_MATCHING PATTERN "*.h")
161
162
163
ENDIF (WITH_ZINRI)

IF (WITH_QT)
164
	add_definitions(-DWITH_QT)
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
165
	find_package(Qt REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
166
	SET(QT_USE_QTCORE TRUE)
167
168
	SET(QT_USE_QTOPENGL TRUE)
	SET(QT_USE_QTSVG TRUE)
Sylvain Thery's avatar
Sylvain Thery committed
169
	SET(QT_USE_QTXML TRUE )
170
171
	INCLUDE(${QT_USE_FILE})
	ADD_DEFINITIONS(${QT_DEFINITIONS})
Sylvain Thery's avatar
Sylvain Thery committed
172
173
	find_package(QGLViewer REQUIRED)
	SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
Sylvain Thery's avatar
Sylvain Thery committed
174
	SET (CGoGN_EXT_LIBS ${QGLVIEWER_LIBRARIES} ${QT_LIBRARIES} ${CGoGN_EXT_LIBS})
175
176
ENDIF (WITH_QT)

177
178
179
180
IF (WITH_GLEWMX)
	ADD_DEFINITIONS(-DGLEW_MX)
ENDIF (WITH_GLEWMX)

Pierre Kraemer's avatar
Pierre Kraemer committed
181
# qq definition specifiques pour mac
Thery Sylvain's avatar
Thery Sylvain committed
182
#IF(APPLE)
Sylvain Thery's avatar
Sylvain Thery committed
183
#	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_OSX")	
Thery Sylvain's avatar
Thery Sylvain committed
184
185
186
#	SET(CMAKE_OSX_ARCHITECTURES x86_64)
#	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} "-framework Foundation -framework cocoa" )
#ENDIF(APPLE)
Pierre Kraemer's avatar
Pierre Kraemer committed
187
188

IF(WIN32)
unknown's avatar
unknown committed
189
190
	set(CMAKE_CONFIGURATION_TYPES Release Debug)
	set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
Sylvain Thery's avatar
Sylvain Thery committed
191
ELSE()
Sylvain Thery's avatar
Sylvain Thery committed
192
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
193
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
Sylvain Thery's avatar
Sylvain Thery committed
194
195
196
197
198
199
200
	# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
	if(CMAKE_COMPILER_IS_GNUCXX)
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
		if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
			SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs")
		endif(GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
Sylvain Thery's avatar
Sylvain Thery committed
201
202
203
	endif()
ENDIF()

Thery Sylvain's avatar
Thery Sylvain committed
204
205
206
if(APPLE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
endif()
207

Sylvain Thery's avatar
Sylvain Thery committed
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316

IF(WIN32)
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib)
ELSE()
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
ENDIF()

include_directories(
	${CMAKE_CURRENT_BINARY_DIR}
	${CGoGN_ROOT_DIR}/include
	${CGoGN_EXT_INCLUDES}
)

file(
	GLOB_RECURSE
	files_topology
	${CGoGN_ROOT_DIR}/src/Topology/*.cpp
	${CGoGN_ROOT_DIR}/include/Topology/*.hpp
	${CGoGN_ROOT_DIR}/include/Topology/*.h
)

file(
	GLOB_RECURSE
	files_container
	${CGoGN_ROOT_DIR}/src/Container/*.cpp
	${CGoGN_ROOT_DIR}/include/Container/*.hpp
	${CGoGN_ROOT_DIR}/include/Container/*.h
)

file(
	GLOB_RECURSE
	files_algo
	${CGoGN_ROOT_DIR}/src/Algo/*.cpp
	${CGoGN_ROOT_DIR}/src/Algo/*.c
	${CGoGN_ROOT_DIR}/include/Algo/*.hpp
	${CGoGN_ROOT_DIR}/include/Algo/*.h
)

file(
	GLOB
	shaders_src
	${CGoGN_ROOT_DIR}/include/Utils/*.frag
	${CGoGN_ROOT_DIR}/include/Utils/*.vert
	${CGoGN_ROOT_DIR}/include/Utils/*.geom	
	${CGoGN_ROOT_DIR}/include/Utils/Shaders/*.frag
	${CGoGN_ROOT_DIR}/include/Utils/Shaders/*.vert
	${CGoGN_ROOT_DIR}/include/Utils/Shaders/*.geom
)


IF(WIN32)
	add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/bin/Release/shader_to_h ${shaders_src}
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
	SOURCES ${shaders_src} )
ELSE()
	add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/bin/shader_to_h ${shaders_src}
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
	SOURCES ${shaders_src} )
ENDIF()


file(
	GLOB		# WARNING NO MORE RECURSE TO AVOID TAKING QT FILES
	files_utils
	${CGoGN_ROOT_DIR}/src/Utils/*.cpp
	${CGoGN_ROOT_DIR}/include/Utils/*.hpp
	${CGoGN_ROOT_DIR}/include/Utils/*.h

	${CGoGN_ROOT_DIR}/src/Utils/Shaders/*.cpp
	${CGoGN_ROOT_DIR}/include/Utils/Shaders/*.hpp
	${CGoGN_ROOT_DIR}/include/Utils/Shaders/*.h
)

IF(WITH_QT)
	file(
		GLOB
		files_utils_qt
		${CGoGN_ROOT_DIR}/src/Utils/Qt/*.cpp
		${CGoGN_ROOT_DIR}/include/Utils/Qt/*.hpp
		${CGoGN_ROOT_DIR}/include/Utils/Qt/*.h
	)
	file(
		GLOB
		utils_qt_headers
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtgl.h
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtSimple.h
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV_glw.h
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV.h
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtpopup.h
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qthistodraw.h 
		${CGoGN_ROOT_DIR}/include/Utils/Qt/qtcolorschooser.h
	)	
		
	QT4_WRAP_CPP(UTILS_QT_HEADERS_MOC ${utils_qt_headers})
	SET (files_utils_withQt ${files_utils} ${files_utils_qt} ${UTILS_QT_HEADERS_MOC})
ENDIF()

file(	GLOB_RECURSE
		files_geometry
		${CGoGN_ROOT_DIR}/include/Geometry/*.h
		${CGoGN_ROOT_DIR}/include/Geometry/*.hpp
)

file(	GLOB_RECURSE
		files_thirdParty
		${CGoGN_ROOT_DIR}/ThirdParty/include/*.h
		${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp
)

317
318
link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )

Sylvain Thery's avatar
Sylvain Thery committed
319
320
321
322
323
324
IF (ONELIB)
	IF(WITH_QT)
		add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt}) 
	ELSE()
		add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} )
	ENDIF()
325
326
327
	add_dependencies(cgogn shader_target)
	target_link_libraries(cgogn ${CGoGN_EXT_LIBS})

Sylvain Thery's avatar
Sylvain Thery committed
328
329
330
331
332
333
ELSE()
	IF (WITH_QT)
		add_library( utils ${files_utils_withQt} )
	ELSE()
		add_library( utils ${files_utils} )
	ENDIF()
334
335
	target_link_libraries(utils ${CGoGN_EXT_LIBS})

336
	add_library( container	${files_container})
337
338
	target_link_libraries(container utils)

339
	add_library( topology	${files_topology})
340
341
	target_link_libraries(topology container)

342
	add_library( algo		${files_algo})
343
344
345
	target_link_libraries(algo utils topology)


Sylvain Thery's avatar
Sylvain Thery committed
346
347
348
349
350
351
352
353
	add_custom_target( Geometry 	SOURCES ${files_geometry} )
	add_custom_target( ThirdParty 	SOURCES ${files_thirdParty} )
	add_dependencies( utils shader_target )
ENDIF()


add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)