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

schultezub's avatar
schultezub committed
3
4
SET(CampvisHome ${CMAKE_CURRENT_SOURCE_DIR})
MESSAGE(STATUS "TUMVis Home: ${CampvisHome}")
schultezub's avatar
schultezub committed
5
6

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

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


# set binary output path
schultezub's avatar
schultezub committed
56
57
58
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CampvisHome}/bin")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CampvisHome}/bin")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CampvisHome}/bin")
schultezub's avatar
schultezub committed
59
60

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

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

    # 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
80
81
    #LIST(APPEND CampvisGlobalDefinitions /wd4305 /wd4800 /wd4290 /wd4068 /wd4251 /wd4355 /wd4390)
    LIST(APPEND CampvisGlobalDefinitions /wd4290 /wd4390)
schultezub's avatar
schultezub committed
82
83
    
    # enable parallel builds in Visual Studio
schultezub's avatar
schultezub committed
84
    LIST(APPEND CampvisGlobalDefinitions /MP)
schultezub's avatar
schultezub committed
85
86

    # prevent error: number of sections exceeded object file format limit
schultezub's avatar
schultezub committed
87
    LIST(APPEND CampvisGlobalDefinitions /bigobj)
schultezub's avatar
schultezub committed
88
89
90
91
92
    
    # 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
93
    IF(CAMPVIS_SHARED_LIBS)
schultezub's avatar
schultezub committed
94
        # Linking against Windows DLLs requires explicit instantiation of templates
schultezub's avatar
schultezub committed
95
        LIST(APPEND CampvisGlobalDefinitions "-DDLL_TEMPLATE_INST")
schultezub's avatar
schultezub committed
96

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

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


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

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

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

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

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

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

191
192
193
194
195
196

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

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

schultezub's avatar
schultezub committed
200
201
# remove CMake and SVN realated directories from list
LIST(REMOVE_ITEM ModDirs CMakeFiles campvis-modules.dir .svn)
202
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})
        MESSAGE(STATUS "* Found Module ${ModDir}")
        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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
            
            # unset module settings to avoid duplicates if module cmake file misses sth.
            UNSET(ThisModDefinitions)
            UNSET(ThisModIncludeDirs)
            UNSET(ThisModExternalLibs)
            UNSET(ThisModSources)
            UNSET(ThisModHeaders)
            
        ELSEIF(NOT DEFINED CAMPVIS_BUILD_MODULE_${ModDirUpper})
            # add a CMake option for building this module
            OPTION(CAMPVIS_BUILD_MODULE_${ModDirUpper}  "Build Module ${ModDir}" OFF)
        ENDIF(CAMPVIS_BUILD_MODULE_${ModDirUpper})
        
    ELSE(EXISTS ${ModFile})
        MESSAGE(STATUS "* WARNING: Found Directory ${ModDir} Without CMake file - ignored")
    ENDIF(EXISTS ${ModFile})
    
ENDFOREACH(ModDir ${ModDirs})

schultezub's avatar
schultezub committed
244
245
246
SET(CommonconfProcessed TRUE)
ENDIF(NOT CommonconfProcessed)