commonconf.cmake 10.2 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})
schultezub's avatar
schultezub committed
4
5
MESSAGE(STATUS "TUMVis Source Directory: ${CampvisHome}")
MESSAGE(STATUS "TUMVis Binary Directory: ${CMAKE_BINARY_DIR}")
schultezub's avatar
schultezub committed
6
7

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

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


# set binary output path
schultezub's avatar
schultezub committed
57
58
59
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
60
61

# common include directories
schultezub's avatar
schultezub committed
62
63
LIST(APPEND CampvisGlobalIncludeDirs "${CampvisHome}/ext")
LIST(APPEND CampvisGlobalIncludeDirs ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 
schultezub's avatar
schultezub committed
64
65
66

# platform-dependent configuration
IF(WIN32)
schultezub's avatar
schultezub committed
67
    LIST(APPEND CampvisGlobalDefinitions "-DNOMINMAX" "-D_CRT_SECURE_NO_DEPRECATE")
schultezub's avatar
schultezub committed
68
69
70
71
72
73
74
75
76
77
78
79
80

    # Disable warnings for Microsoft compiler:
    # C4305: 'identifier' : truncation from 'type1' to 'type2'
    # C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning
    # C4290: C++ exception specification ignored except to indicate a function is
    #        not __declspec(nothrow)
    # C4068: unknown pragma
    # C4251  class needs to have dll interface (used for std classes)
    # C4355: 'this' : used in base member initializer list 
    #        occurs in processors' constructors when initializing event properties, 
    #        but is safe there, since the 'this' pointer is only stored and not accessed.
    # C4390: ';' : empty controlled statement found; is this the intent?
    #        occurs when OpenGL error logging macros are disabled
schultezub's avatar
schultezub committed
81
82
    #LIST(APPEND CampvisGlobalDefinitions /wd4305 /wd4800 /wd4290 /wd4068 /wd4251 /wd4355 /wd4390)
    LIST(APPEND CampvisGlobalDefinitions /wd4290 /wd4390)
schultezub's avatar
schultezub committed
83
84
    
    # enable parallel builds in Visual Studio
schultezub's avatar
schultezub committed
85
    LIST(APPEND CampvisGlobalDefinitions /MP)
schultezub's avatar
schultezub committed
86
87

    # prevent error: number of sections exceeded object file format limit
schultezub's avatar
schultezub committed
88
    LIST(APPEND CampvisGlobalDefinitions /bigobj)
schultezub's avatar
schultezub committed
89
90
91
92
93
    
    # 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")

schultezub's avatar
schultezub committed
94
    IF(CAMPVIS_SHARED_LIBS)
schultezub's avatar
schultezub committed
95
        # Linking against Windows DLLs requires explicit instantiation of templates
schultezub's avatar
schultezub committed
96
        LIST(APPEND CampvisGlobalDefinitions "-DDLL_TEMPLATE_INST")
schultezub's avatar
schultezub committed
97

schultezub's avatar
schultezub committed
98
        IF(NOT CAMPVIS_GENERATE_MANIFEST)
schultezub's avatar
schultezub committed
99
100
101
102
103
104
105
            # 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
106
    If(CAMPVIS_INCREMENTAL_LINKING)
schultezub's avatar
schultezub committed
107
108
109
110
111
112
113
        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
114
    LIST(APPEND CampvisGlobalExternalLibs netapi32 version)
115
    
schultezub's avatar
schultezub committed
116
ELSEIF(UNIX)
schultezub's avatar
schultezub committed
117
118
    LIST(APPEND CampvisGlobalDefinitions "-DUNIX")  
    LIST(APPEND CampvisGlobalDefinitions "-D__STDC_CONSTANT_MACROS")  
schultezub's avatar
schultezub committed
119
120
121
ENDIF(WIN32)

# tgt configuration
schultezub's avatar
schultezub committed
122
LIST(APPEND CampvisGlobalDefinitions "-DTGT_WITHOUT_DEFINES") # don't use tgt's build system
schultezub's avatar
schultezub committed
123
124
125
IF(WIN32)
    SET(TGT_WITH_WMI TRUE)  #< enable Windows Management Instrumentation for hardware detection
ENDIF()
schultezub's avatar
schultezub committed
126
IF(CAMPVIS_DEBUG)
schultezub's avatar
schultezub committed
127
    LIST(APPEND CampvisGlobalDefinitions -DTGT_DEBUG -DCAMPVIS_DEBUG)
schultezub's avatar
schultezub committed
128
129
130
ENDIF()
 
# minimum Qt version
schultezub's avatar
schultezub committed
131
SET(CampvisRequiredQtVersion "4.8")
schultezub's avatar
schultezub committed
132
133
134
135


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

schultezub's avatar
schultezub committed
138
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CampvisHome}/cmake")
schultezub's avatar
schultezub committed
139
140
141
142
143

# OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
IF(OPENGL_FOUND)
    MESSAGE(STATUS "* Found OpenGL")
schultezub's avatar
schultezub committed
144
145
    LIST(APPEND CampvisGlobalIncludeDirs ${OPENGL_INCLUDE_DIR})
    LIST(APPEND CampvisGlobalExternalLibs ${OPENGL_LIBRARIES})
schultezub's avatar
schultezub committed
146
147
148
149
150
151
152
153
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
154
155
156
157
158
159
    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
160
161
162
163
ELSE(GLEW_FOUND)
    MESSAGE(FATAL_ERROR "GLEW not found!")
ENDIF(GLEW_FOUND)

schultezub's avatar
schultezub committed
164
165
166
167
# TBB
FIND_PACKAGE(TBB REQUIRED)
IF(TBB_FOUND)
    MESSAGE(STATUS "* Found TBB")
schultezub's avatar
schultezub committed
168
169
170
171
172
173
    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
174
175
176
177
ELSE(TBB_FOUND)
    MESSAGE(FATAL_ERROR "TBB not found!")
ENDIF(TBB_FOUND)

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

182
# OpenCL
schultezub's avatar
schultezub committed
183
184
FIND_PACKAGE(CL)
IF (OPENCL_FOUND)
185
    MESSAGE(STATUS "* Found OpenCL")
schultezub's avatar
schultezub committed
186
187
    LIST(APPEND CampvisGlobalIncludeDirs ${OPENCL_INCLUDE_DIR})
    LIST(APPEND CampvisGlobalExternalLibs ${OPENCL_LIBRARY})
188
ELSE(OPENCL_FOUND)
schultezub's avatar
schultezub committed
189
    MESSAGE(STATUS "* Did NOT find OpenCL!")
190
ENDIF(OPENCL_FOUND)
schultezub's avatar
schultezub committed
191

192
193
194
195
196
197

# detect modules
MESSAGE(STATUS "--------------------------------------------------------------------------------")
MESSAGE(STATUS "Detecting installed modules:")

# collect list of directories in modules directories
schultezub's avatar
schultezub committed
198
SET(ModulesDir ${CampvisHome}/modules)
199
200
LIST_SUBDIRECTORIES(ModDirs ${ModulesDir} false)

schultezub's avatar
schultezub committed
201
202
# remove CMake and SVN realated directories from list
LIST(REMOVE_ITEM ModDirs CMakeFiles campvis-modules.dir .svn)
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

# go through each subdirectory
FOREACH(ModDir ${ModDirs})
    # check whether  module.cmake file exists
    SET(ModFile ${ModulesDir}/${ModDir}/${ModDir}.cmake)
    IF(EXISTS ${ModFile})
        STRING(TOLOWER ${ModDir} ModDirLower)
        STRING(TOUPPER ${ModDir} ModDirUpper)

        # check whether the option to build this very module exists and is checked
        IF(CAMPVIS_BUILD_MODULE_${ModDirUpper})
            SET(ThisModDir ${ModulesDir}/${ModDir})
            
            # load .cmake file
            INCLUDE(${ModFile})
            
            # merge module settings into global settings
schultezub's avatar
schultezub committed
220
221
222
223
224
            LIST(APPEND CampvisModulesDefinitions ${ThisModDefinitions})
            LIST(APPEND CampvisModulesIncludeDirs ${ThisModIncludeDirs})
            LIST(APPEND CampvisModulesExternalLibs ${ThisModExternalLibs})
            LIST(APPEND CampvisModulesSources ${ThisModSources})
            LIST(APPEND CampvisModulesHeaders ${ThisModHeaders})
225
226
227
228
229
            LIST(APPEND CampvisModulesCoreSources ${ThisModCoreSources})
            LIST(APPEND CampvisModulesCoreHeaders ${ThisModCoreHeaders})
            
            # add definition that this module is activated
            LIST(APPEND CampvisGlobalDefinitions -DCAMPVIS_HAS_MODULE_${ModDirUpper})
230
231
232
233
234
235
236
            
            # unset module settings to avoid duplicates if module cmake file misses sth.
            UNSET(ThisModDefinitions)
            UNSET(ThisModIncludeDirs)
            UNSET(ThisModExternalLibs)
            UNSET(ThisModSources)
            UNSET(ThisModHeaders)
237
238
            UNSET(ThisModCoreSources)
            UNSET(ThisModCoreHeaders)
239
            
schultezub's avatar
schultezub committed
240
241
242
243
244
245
            MESSAGE(STATUS "* Found Module '${ModDir}' . ENABLED")
        ELSE()
            MESSAGE(STATUS "* Found Module '${ModDir}'")
        ENDIF(CAMPVIS_BUILD_MODULE_${ModDirUpper})
        
        IF(NOT DEFINED CAMPVIS_BUILD_MODULE_${ModDirUpper})
246
247
            # add a CMake option for building this module
            OPTION(CAMPVIS_BUILD_MODULE_${ModDirUpper}  "Build Module ${ModDir}" OFF)
schultezub's avatar
schultezub committed
248
        ENDIF(NOT DEFINED CAMPVIS_BUILD_MODULE_${ModDirUpper})
249
250
251
252
253
254
255
        
    ELSE(EXISTS ${ModFile})
        MESSAGE(STATUS "* WARNING: Found Directory ${ModDir} Without CMake file - ignored")
    ENDIF(EXISTS ${ModFile})
    
ENDFOREACH(ModDir ${ModDirs})

schultezub's avatar
schultezub committed
256
257
SET(CommonconfProcessed TRUE)
ENDIF(NOT CommonconfProcessed)