CMakeLists.txt 6.79 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

project(CGoGN)
4
#cmake_policy(SET CMP0042 NEW) # rpath new policy
Pierre Kraemer's avatar
Pierre Kraemer committed
5

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

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

10 11
SET ( CGoGN_SRC_DIR ${CMAKE_SOURCE_DIR}/CGoGN)

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

Sylvain Thery's avatar
Sylvain Thery committed
14

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
# ====== 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
38
# ======== Check  Build Type =============
Sylvain Thery's avatar
Sylvain Thery committed
39 40 41 42 43 44 45 46
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
47

Sylvain Thery's avatar
Sylvain Thery committed
48 49 50 51 52 53 54 55 56
# for shared or not shared (default except on windows)

if(WIN32)
	SET ( BUILD_SHARED_LIBS OFF CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
else()
	SET ( BUILD_SHARED_LIBS ON CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
endif()


57

Sylvain Thery's avatar
Sylvain Thery committed
58 59
#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
60 61 62 63 64 65 66 67 68 69 70
	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()

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

Sylvain Thery's avatar
Sylvain Thery committed
74 75 76 77 78
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" )
79 80


Sylvain Thery's avatar
Sylvain Thery committed
81
#create one big lib 
82 83
SET ( ONELIB OFF CACHE BOOL "build CGoGN in one lib" )

Sylvain Thery's avatar
Sylvain Thery committed
84

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

Sylvain Thery's avatar
Sylvain Thery committed
88 89

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

thery's avatar
thery committed
93
find_package(OpenGL REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
94 95
find_package(ZLIB REQUIRED)
find_package(GLEW REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
96

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


101 102 103 104 105 106
IF (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
ELSE (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=false)
ENDIF (DEFINED ASSERTON)

107
IF (ONELIB)
108
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "1" )
109
ELSE (ONELIB)
110
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "0" )
111 112
ENDIF (ONELIB)

113
IF (WITH_GLEWMX)
114
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "1" )
115
ELSE (WITH_GLEWMX)
116
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "0" )
117 118 119
ENDIF (WITH_GLEWMX)


120 121 122 123
IF(USE_OGL_CORE_PROFILE)
	add_definitions(-DUSE_OGL_CORE_PROFILE=1)
ENDIF()

Sylvain Thery's avatar
Sylvain Thery committed
124
add_definitions(-DGLM_FORCE_RADIANS)
125

126 127
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")

Sylvain Thery's avatar
Sylvain Thery committed
128
# define includes of external libs 
129 130
SET (CGoGN_EXT_INCLUDES
	${CGoGN_ROOT_DIR}/ThirdParty/include
Sylvain Thery's avatar
Sylvain Thery committed
131 132 133
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
134
)
Sylvain Thery's avatar
Sylvain Thery committed
135 136

# define libs for external libs
137
SET (CGoGN_EXT_LIBS
138
    	nl
Sylvain Thery's avatar
Sylvain Thery committed
139 140 141
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
142
	tinyxml2
143
)
144

145 146 147 148 149 150 151 152 153
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
154
	SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${SUITESPARSE_INCLUDE_DIRS})
155
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} ${SUITESPARSE_LIBRARIES} pthread)
156 157
ENDIF(WIN32)

unknown's avatar
unknown committed
158

159
#optionnal libs
Sylvain Thery's avatar
Sylvain Thery committed
160
IF (WITH_ASSIMP)
161
	add_definitions(-DWITH_ASSIMP)	
162
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} assimp)
Sylvain Thery's avatar
Sylvain Thery committed
163
#	INSTALL (DIRECTORY ThirdParty/Assimp/include  DESTINATION .)
Sylvain Thery's avatar
Sylvain Thery committed
164 165
ENDIF (WITH_ASSIMP)

166 167 168
IF (WITH_ZINRI)
	add_definitions(-DWITH_ZINRI)
	SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} Zinri)
Sylvain Thery's avatar
Sylvain Thery committed
169
#	INSTALL (DIRECTORY ThirdParty/Zinri/ DESTINATION include FILES_MATCHING PATTERN "*.h")
170 171 172
ENDIF (WITH_ZINRI)

IF (WITH_QT)
173
	add_definitions(-DWITH_QT)
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
174
	find_package(Qt REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
175
	SET(QT_USE_QTCORE TRUE)
176 177
	SET(QT_USE_QTOPENGL TRUE)
	SET(QT_USE_QTSVG TRUE)
Sylvain Thery's avatar
Sylvain Thery committed
178
	SET(QT_USE_QTXML TRUE )
179 180
	INCLUDE(${QT_USE_FILE})
	ADD_DEFINITIONS(${QT_DEFINITIONS})
Sylvain Thery's avatar
Sylvain Thery committed
181 182
	find_package(QGLViewer REQUIRED)
	SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
Sylvain Thery's avatar
Sylvain Thery committed
183
	SET (CGoGN_EXT_LIBS ${QGLVIEWER_LIBRARIES} ${QT_LIBRARIES} ${CGoGN_EXT_LIBS})
184 185
ENDIF (WITH_QT)

186 187 188 189
IF (WITH_GLEWMX)
	ADD_DEFINITIONS(-DGLEW_MX)
ENDIF (WITH_GLEWMX)

Pierre Kraemer's avatar
Pierre Kraemer committed
190
# qq definition specifiques pour mac
Thery Sylvain's avatar
Thery Sylvain committed
191
#IF(APPLE)
Sylvain Thery's avatar
Sylvain Thery committed
192
#	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_OSX")	
Thery Sylvain's avatar
Thery Sylvain committed
193 194 195
#	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
196 197

IF(WIN32)
unknown's avatar
unknown committed
198 199
	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
200
ELSE()
Sylvain Thery's avatar
Sylvain Thery committed
201
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
202
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
Sylvain Thery's avatar
Sylvain Thery committed
203 204
	# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
	if(CMAKE_COMPILER_IS_GNUCXX)
Sylvain Thery's avatar
Sylvain Thery committed
205 206
		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs")
Sylvain Thery's avatar
Sylvain Thery committed
207 208 209
	endif()
ENDIF()

Thery Sylvain's avatar
Thery Sylvain committed
210 211 212
if(APPLE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
endif()
213

Sylvain Thery's avatar
Sylvain Thery committed
214 215 216 217 218 219 220 221 222

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}
223
	${CGoGN_SRC_DIR}/include
Sylvain Thery's avatar
Sylvain Thery committed
224 225 226
	${CGoGN_EXT_INCLUDES}
)

227
add_subdirectory(${CGoGN_SRC_DIR} CGoGN)
Sylvain Thery's avatar
Sylvain Thery committed
228 229 230 231 232



add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)