commonconf.cmake 9.25 KB
Newer Older
schultezub's avatar
schultezub committed
1
IF(NOT CommonconfProcessed)
schultezub's avatar
schultezub committed
2

schultezub's avatar
schultezub committed
3
SET(CampvisHome ${CMAKE_CURRENT_SOURCE_DIR})
4
SET(CampvisBinaryDir ${CMAKE_BINARY_DIR})
schultezub's avatar
schultezub committed
5
MESSAGE(STATUS "TUMVis Source Directory: ${CampvisHome}")
6
MESSAGE(STATUS "TUMVis Binary Directory: ${CampvisBinaryDir}")
schultezub's avatar
schultezub committed
7
8

# include macros
schultezub's avatar
schultezub committed
9
INCLUDE(${CampvisHome}/cmake/macros.cmake)
schultezub's avatar
schultezub committed
10
11
12

# detect compiler and architecture
IF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 9 2008")
schultezub's avatar
schultezub committed
13
14
    SET(CAMPVIS_MSVC2008 TRUE)
    SET(CAMPVIS_WIN32 TRUE)
schultezub's avatar
schultezub committed
15
16
    MESSAGE(STATUS "Visual Studio 2008 build (32 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 9 2008 Win64")
schultezub's avatar
schultezub committed
17
18
    SET(CAMPVIS_MSVC2008 TRUE)
    SET(CAMPVIS_WIN64 TRUE)
schultezub's avatar
schultezub committed
19
20
    MESSAGE(STATUS "Visual Studio 2008 Build (64 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 10")
schultezub's avatar
schultezub committed
21
22
    SET(CAMPVIS_MSVC2010 TRUE)
    SET(CAMPVIS_WIN32 TRUE)
schultezub's avatar
schultezub committed
23
24
    MESSAGE(STATUS "Visual Studio 2010 Build (32 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 10 Win64")
schultezub's avatar
schultezub committed
25
26
    SET(CAMPVIS_MSVC2010 TRUE)
    SET(CAMPVIS_WIN64 TRUE)
schultezub's avatar
schultezub committed
27
28
    MESSAGE(STATUS "Visual Studio 2010 Build (64 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 11")
schultezub's avatar
schultezub committed
29
30
    SET(CAMPVIS_MSVC11 TRUE)
    SET(CAMPVIS_WIN32 TRUE)
31
    MESSAGE("Visual Studio 11 Build (32 Bit)")
schultezub's avatar
schultezub committed
32
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 11 Win64")
schultezub's avatar
schultezub committed
33
34
    SET(CAMPVIS_MSVC11 TRUE)
    SET(CAMPVIS_WIN64 TRUE)
35
36
37
38
39
40
41
42
43
    MESSAGE("Visual Studio 11 Build (64 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 12")
    SET(CAMPVIS_MSVC12 TRUE)
    SET(CAMPVIS_WIN32 TRUE)
    MESSAGE("Visual Studio 12 Build (32 Bit)")
ELSEIF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 Win64")
    SET(CAMPVIS_MSVC12 TRUE)
    SET(CAMPVIS_WIN64 TRUE)
    MESSAGE("Visual Studio 12 Build (64 Bit)")
schultezub's avatar
schultezub committed
44
ELSEIF(${CMAKE_GENERATOR} MATCHES "NMake") 
schultezub's avatar
schultezub committed
45
    SET(CAMPVIS_NMAKE TRUE)
46
47
48
49
50
51
52
53

    # NMake-based builds may very well use a Visual Studio compiler
    IF(MSVC90)
        SET(CAMPVIS_MSVC2008 TRUE)
    ELSEIF(MSVC10)
        SET(CAMPVIS_MSVC2010 TRUE)
    ELSEIF(MSVC11)
        SET(CAMPVIS_MSVC11 TRUE)
54
55
    ELSEIF(MSVC12)
        SET(CAMPVIS_MSVC12 TRUE)
56
57
    ENDIF(MSVC90)

schultezub's avatar
schultezub committed
58
    IF(CMAKE_CL_64)
schultezub's avatar
schultezub committed
59
        SET(CAMPVIS_WIN64 TRUE)
schultezub's avatar
schultezub committed
60
61
        MESSAGE(STATUS "NMake 64 Bit Build")
    ELSE(CMAKE_CL_64)
schultezub's avatar
schultezub committed
62
        SET(CAMPVIS_WIN32 TRUE)
schultezub's avatar
schultezub committed
63
64
65
        MESSAGE(STATUS "NMake 32 Bit Build")            
    ENDIF(CMAKE_CL_64)    
ELSEIF(${CMAKE_GENERATOR} MATCHES "MinGW")
schultezub's avatar
schultezub committed
66
67
    SET(CAMPVIS_MINGW TRUE)
    SET(CAMPVIS_WIN32 TRUE)
schultezub's avatar
schultezub committed
68
69
    MESSAGE("MinGW 32 Bit Build (not actively supported)")
ELSEIF(${CMAKE_GENERATOR} MATCHES "Unix")
schultezub's avatar
schultezub committed
70
    SET(CAMPVIS_UNIX TRUE)
schultezub's avatar
schultezub committed
71
72
73
74
75
76
77
    MESSAGE(STATUS "Unix Build")
ELSE()
    MESSAGE(WARNING "Unsupported or unknown generator: ${CMAKE_GENERATOR}")
ENDIF()


# set binary output path
schultezub's avatar
schultezub committed
78
79
80
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
schultezub's avatar
schultezub committed
81
82

# common include directories
schultezub's avatar
schultezub committed
83
84
LIST(APPEND CampvisGlobalIncludeDirs "${CampvisHome}/ext")
LIST(APPEND CampvisGlobalIncludeDirs ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 
schultezub's avatar
schultezub committed
85

86
87
LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_SOURCE_DIR=\"${CampvisHome}\"")

schultezub's avatar
schultezub committed
88
89
# platform-dependent configuration
IF(WIN32)
schultezub's avatar
schultezub committed
90
    LIST(APPEND CampvisGlobalDefinitions "-DNOMINMAX" "-D_CRT_SECURE_NO_DEPRECATE")
schultezub's avatar
schultezub committed
91
92

    # Disable warnings for Microsoft compiler:
93
    # C4251  class needs to have dll interface (used for std classes)
schultezub's avatar
schultezub committed
94
95
96
97
    # C4290: C++ exception specification ignored except to indicate a function is
    #        not __declspec(nothrow)
    # C4390: ';' : empty controlled statement found; is this the intent?
    #        occurs when OpenGL error logging macros are disabled
98
99
100
    # C4503: The decorated name was longer than the compiler limit (4096), and was truncated.
    #        Occurs in AutoEvaluatePipeline due to some nested nested map-iterator-map. Could
    #        not be deactivated locally...
101
    LIST(APPEND CampvisGlobalDefinitions /wd4251 /wd4290 /wd4390 /wd4503)
schultezub's avatar
schultezub committed
102
103
    
    # enable parallel builds in Visual Studio
schultezub's avatar
schultezub committed
104
    LIST(APPEND CampvisGlobalDefinitions /MP)
schultezub's avatar
schultezub committed
105
106

    # prevent error: number of sections exceeded object file format limit
schultezub's avatar
schultezub committed
107
    LIST(APPEND CampvisGlobalDefinitions /bigobj)
schultezub's avatar
schultezub committed
108
109
110
111
112
    
    # allows 32 Bit builds to use more than 2GB RAM (VC++ only)
    SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
    SET(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")

113
    IF(BUILD_SHARED_LIBS)
schultezub's avatar
schultezub committed
114
        # Linking against Windows DLLs requires explicit instantiation of templates
schultezub's avatar
schultezub committed
115
        LIST(APPEND CampvisGlobalDefinitions "-DDLL_TEMPLATE_INST")
116
        LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_DYNAMIC_LIBS")
schultezub's avatar
schultezub committed
117

schultezub's avatar
schultezub committed
118
        IF(NOT CAMPVIS_GENERATE_MANIFEST)
schultezub's avatar
schultezub committed
119
120
121
122
123
124
125
            # Do not embed manifest into binaries in debug mode (slows down incremental linking)
            SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /MANIFEST:NO")
            SET(CMAKE_EXE_LINKER_FLAGS_DEBUG    "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MANIFEST:NO")
        ENDIF()
    ENDIF()

    # enable/disable incremental linking in debug builds
schultezub's avatar
schultezub committed
126
    If(CAMPVIS_INCREMENTAL_LINKING)
schultezub's avatar
schultezub committed
127
128
129
130
131
132
133
        SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL")
        SET(CMAKE_EXE_LINKER_FLAGS_DEBUG    "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL")
    ELSE()
        SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO")
        SET(CMAKE_EXE_LINKER_FLAGS_DEBUG    "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO")
    ENDIF()
    
schultezub's avatar
schultezub committed
134
    LIST(APPEND CampvisGlobalExternalLibs netapi32 version)
135
136
137
138
139
140
141
142
143
144

    # Append the name of the current build type to the path of the CMake output directory so that
    # NMake places all build artifacts in the same directories as Visual Studio. This makes NMake
    # builds compatible with our macro that copies external DLLs into the build directory.
    IF(CAMPVIS_NMAKE)
        SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
        SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
        SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
    ENDIF(CAMPVIS_NMAKE)

schultezub's avatar
schultezub committed
145
ELSEIF(UNIX)
146
    LIST(APPEND CampvisGlobalDefinitions "-DUNIX")
147
    LIST(APPEND CampvisGlobalDefinitions "-Wall -Wno-unused-local-typedefs -Wno-unused-variable")
148
    LIST(APPEND CampvisGlobalDefinitions "-D__STDC_CONSTANT_MACROS")
schultezub's avatar
schultezub committed
149
150
ENDIF(WIN32)

151
152
153
154
155
156
157
IF(CMAKE_COMPILER_IS_GNUCXX)
    # enable C++11 support in GCC
    LIST(APPEND CMAKE_CXX_FLAGS "-std=c++11")
    # however: we want to use the TBB implementation of threads
    LIST(APPEND CampvisGlobalDefinitions "-DTBB_IMPLEMENT_CPP0X")
ENDIF()

schultezub's avatar
schultezub committed
158
# tgt configuration
schultezub's avatar
schultezub committed
159
LIST(APPEND CampvisGlobalDefinitions "-DTGT_WITHOUT_DEFINES") # don't use tgt's build system
schultezub's avatar
schultezub committed
160
161
162
IF(WIN32)
    SET(TGT_WITH_WMI TRUE)  #< enable Windows Management Instrumentation for hardware detection
ENDIF()
schultezub's avatar
schultezub committed
163
IF(CAMPVIS_DEBUG)
164
#    SET_PROPERTY(GLOBAL PROPERTY COMPILE_DEFINITIONS_DEBUG TGT_DEBUG CAMPVIS_DEBUG)
schultezub's avatar
schultezub committed
165
    LIST(APPEND CampvisGlobalDefinitions -DTGT_DEBUG -DCAMPVIS_DEBUG)
166
#    set_property(GLOBAL PROPERTY COMPILE_DEFINITIONS_DEBUG "TGT_DEBUG CAMPVIS_DEBUG")
schultezub's avatar
schultezub committed
167
168
169
ENDIF()
 
# minimum Qt version
170
IF(CAMPVIS_BUILD_APPLICATION)
171
172
    FIND_PACKAGE(Qt4 ${CampvisRequiredQtVersion} REQUIRED QtCore QtGui QtOpenGL)
    INCLUDE(${QT_USE_FILE})
173
174
175
    SET(TGT_WITH_QT true)
    SET(CampvisRequiredQtVersion "4.8")
ENDIF(CAMPVIS_BUILD_APPLICATION)
schultezub's avatar
schultezub committed
176
177
178
179


# detect libraries
MESSAGE(STATUS "--------------------------------------------------------------------------------")
schultezub's avatar
schultezub committed
180
MESSAGE(STATUS "Detecting Mandatory External Libraries:")
schultezub's avatar
schultezub committed
181

schultezub's avatar
schultezub committed
182
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CampvisHome}/cmake")
schultezub's avatar
schultezub committed
183
184
185
186
187

# OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
IF(OPENGL_FOUND)
    MESSAGE(STATUS "* Found OpenGL")
schultezub's avatar
schultezub committed
188
189
    LIST(APPEND CampvisGlobalIncludeDirs ${OPENGL_INCLUDE_DIR})
    LIST(APPEND CampvisGlobalExternalLibs ${OPENGL_LIBRARIES})
schultezub's avatar
schultezub committed
190
191
192
193
194
195
196
197
ELSE(OPENGL_FOUND)
    MESSAGE(FATAL_ERROR "OpenGL not found!")
ENDIF(OPENGL_FOUND)
    
# GLEW
FIND_PACKAGE(Glew REQUIRED)
IF(GLEW_FOUND)
    MESSAGE(STATUS "* Found GLEW")
schultezub's avatar
schultezub committed
198
199
200
201
202
203
    LIST(APPEND CampvisGlobalDefinitions ${GLEW_DEFINITIONS})
    LIST(APPEND CampvisGlobalIncludeDirs ${GLEW_INCLUDE_DIR})
    LIST(APPEND CampvisGlobalExternalLibs ${GLEW_LIBRARY})
    LIST(APPEND CampvisExternalDllsDebug ${GLEW_DLL_DEBUG})
    LIST(APPEND CampvisExternalDllsRelease ${GLEW_DLL_RELEASE})
    LIST(APPEND CampvisExternalLicenseFiles ${GLEW_LICENSE_FILE})
schultezub's avatar
schultezub committed
204
205
206
207
ELSE(GLEW_FOUND)
    MESSAGE(FATAL_ERROR "GLEW not found!")
ENDIF(GLEW_FOUND)

schultezub's avatar
schultezub committed
208
209
210
211
# TBB
FIND_PACKAGE(TBB REQUIRED)
IF(TBB_FOUND)
    MESSAGE(STATUS "* Found TBB")
schultezub's avatar
schultezub committed
212
213
214
215
216
217
    LIST(APPEND CampvisGlobalDefinitions ${TBB_DEFINITIONS})
    LIST(APPEND CampvisGlobalIncludeDirs ${TBB_INCLUDE_DIR})
    LIST(APPEND CampvisGlobalExternalLibs ${TBB_LIBRARY})
    LIST(APPEND CampvisExternalDllsDebug ${TBB_DLL_DEBUG})
    LIST(APPEND CampvisExternalDllsRelease ${TBB_DLL_RELEASE})
    LIST(APPEND CampvisExternalLicenseFiles ${TBB_LICENSE_FILE})
schultezub's avatar
schultezub committed
218
219
220
221
ELSE(TBB_FOUND)
    MESSAGE(FATAL_ERROR "TBB not found!")
ENDIF(TBB_FOUND)

schultezub's avatar
schultezub committed
222
223
224
225
226
227
228
229
# Eigen
IF(EXISTS "${CampvisHome}/ext/eigen/Eigen/Eigen")
    MESSAGE(STATUS "* Found Eigen")
    LIST(APPEND CampvisGlobalIncludeDirs "${CampvisHome}/ext/eigen")
    LIST(APPEND CampvisGlobalDefinitions -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS)
ELSE()
    MESSAGE(WARNING "Did not find Eigen - Eigen library must be placed in ext/eigen/!")
ENDIF()
schultezub's avatar
schultezub committed
230
SET(CommonconfProcessed TRUE)
231

schultezub's avatar
schultezub committed
232
ENDIF(NOT CommonconfProcessed)