apps_cmake.txt 3.61 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1
# How make separated applications 
Sylvain Thery's avatar
Sylvain Thery committed
2
#
Sylvain Thery's avatar
Sylvain Thery committed
3
# usage: insert this line in your CMakeLists.txt
Sylvain Thery's avatar
Sylvain Thery committed
4 5 6 7 8 9 10 11
#	include(${CGoGN_ROOT_DIR}/build/apps_cmake.txt)
# just after defining CGoGN_ROOT_DIR
# 
# Example:
# ========
#	cmake_minimum_required(VERSION 2.8)
#	project(Pipo)
#
Sylvain Thery's avatar
Sylvain Thery committed
12
#	LoadQtPackage()
Sylvain Thery's avatar
Sylvain Thery committed
13 14 15 16 17
#
#	set(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN CACHE STRING "CGoGN root dir")
#	include(${CGoGN_ROOT_DIR}/apps_cmake.txt)
#
#	include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
Sylvain Thery's avatar
Sylvain Thery committed
18 19
#	qt_wrap_ui( pipo_ui pipo.ui )
#	qt_wrap_cpp( pipo_moc pipo.h )
Sylvain Thery's avatar
Sylvain Thery committed
20 21 22
#	add_executable( pipo pipo.cpp ${pipo_ui} ${pipo_moc} )
#	target_link_libraries( pipo ${CGoGN_LIBS}  ${CGoGN_EXT_LIBS} )
#
Sylvain Thery's avatar
Sylvain Thery committed
23 24 25 26
#
#	WARNING: to avoid problem of DLL loading, on windows executable are generated in CGoGN/bin/....
#	Take care while choosing executable names
#
Sylvain Thery's avatar
Sylvain Thery committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40

SET ( CGoGN_SRC_DIR ${CGoGN_ROOT_DIR}/CGoGN)
SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ )

INCLUDE(${CGoGN_ROOT_DIR}/cmake_modules/functions.cmake)

checkCpp11Support()
setBuildType()

IF (WIN32)
	SET ( CMAKE_CONFIGURATION_TYPES Release Debug)
	SET ( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
	SET ( CGoGN_WITH_QTCREATOR OFF CACHE BOOL "use QtCreator to compile (instead of Visual Studio" )
ENDIF ()
41 42


Sylvain Thery's avatar
Sylvain Thery committed
43 44 45
IF(WIN32)
	SET ( CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies" )
ENDIF(WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
46

Sylvain Thery's avatar
Sylvain Thery committed
47 48 49 50 51 52 53 54 55 56 57
#
# 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()
Sylvain Thery's avatar
Sylvain Thery committed
58
	IF(APPLE)
Sylvain Thery's avatar
Sylvain Thery committed
59
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
Sylvain Thery's avatar
Sylvain Thery committed
60
	ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
61 62 63
ENDIF()


Sylvain Thery's avatar
Sylvain Thery committed
64 65 66 67 68 69 70 71 72 73 74 75
IF (WIN32)
	link_directories( ${CGoGN_ROOT_DIR}/windows_dependencies/lib/)
	IF((CGoGN_WITH_QTCREATOR))
		link_directories( ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE})
		SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}) # Release/Debug added automatically by visual
	ELSE()
		link_directories( ${CGoGN_ROOT_DIR}/bin/${ConfigurationName})
		message(STATUS ${CGoGN_ROOT_DIR}/bin/${ConfigurationName} )
		SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual
	ENDIF()
ELSE()
	link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
Sylvain Thery's avatar
Sylvain Thery committed
76
	SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE} )
Sylvain Thery's avatar
Sylvain Thery committed
77
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
78

Sylvain Thery's avatar
Sylvain Thery committed
79 80 81 82 83 84 85 86
# Qt version from CGoGN
file(READ ${CGoGN_SRC_DIR}/include/cgogn_qt.h CGoGN_DESIRED_QT_VERSION)
ADD_DEFINITIONS("-DCGOGN_QT_DESIRED_VERSION=${CGoGN_DESIRED_QT_VERSION}")
IF(CGoGN_DESIRED_QT_VERSION STREQUAL 5)
	include(${CGoGN_ROOT_DIR}/cmake_modules/Qt_5x.cmake)
ELSE()
	include(${CGoGN_ROOT_DIR}/cmake_modules/Qt_4x.cmake)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
87 88 89

# CGoGN compiled in one or several libs
file(STRINGS ${CGoGN_SRC_DIR}/include/cgogn_onelib.h ONELIB_STR)
90
IF (ONELIB_STR EQUAL 1)
Sylvain Thery's avatar
Sylvain Thery committed
91 92
	SET(CGoGN_LIBS cgogn)
ELSE()
Sylvain Thery's avatar
Sylvain Thery committed
93
	SET(CGoGN_LIBS topology algo container utils)
Sylvain Thery's avatar
Sylvain Thery committed
94
ENDIF()
95

Sylvain Thery's avatar
Sylvain Thery committed
96 97 98
# definitions from CGoGN
FILE(STRINGS ${CGoGN_SRC_DIR}/include/cgogn_defs.h CGoGN_DEFS)
ADD_DEFINITIONS(${CGoGN_DEFS})
Sylvain Thery's avatar
Sylvain Thery committed
99

Sylvain Thery's avatar
Sylvain Thery committed
100 101
# includes from CGoGN
FILE(STRINGS ${CGoGN_SRC_DIR}/include/cgogn_ext_includes.h CGoGN_EXT_INCLUDES)
Sylvain Thery's avatar
Sylvain Thery committed
102

Sylvain Thery's avatar
Sylvain Thery committed
103 104
# libs from CGoGN
FILE(STRINGS ${CGoGN_SRC_DIR}/include/cgogn_ext_libs.h CGoGN_EXT_LIBS)
105

106

Sylvain Thery's avatar
Sylvain Thery committed
107 108 109
include_directories(
        ${CGoGN_SRC_DIR}/include
        ${CGoGN_EXT_INCLUDES})
110

Sylvain Thery's avatar
Sylvain Thery committed
111 112 113
#for compatibility
SET (COMMON_INCLUDES ${CGoGN_EXT_INCLUDES})
SET (COMMON_LIBS ${CGoGN_EXT_LIBS})
Sylvain Thery's avatar
Sylvain Thery committed
114

115