commonconf.cmake 9.44 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3

IF(NOT COMMONCONF_PROCESSED)

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

# include macros
schultezub's avatar
schultezub committed
8
INCLUDE(${CAMPVIS_HOME}/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 "${CAMPVIS_HOME}/bin")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CAMPVIS_HOME}/bin")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CAMPVIS_HOME}/bin")
schultezub's avatar
schultezub committed
60
61

# common include directories
schultezub's avatar
schultezub committed
62
63
LIST(APPEND CAMPVIS_INCLUDE_DIRECTORIES "${CAMPVIS_HOME}/ext")
LIST(APPEND CAMPVIS_INCLUDE_DIRECTORIES ${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 CAMPVIS_DEFINITIONS "-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 CAMPVIS_DEFINITIONS /wd4305 /wd4800 /wd4290 /wd4068 /wd4251 /wd4355 /wd4390)
    LIST(APPEND CAMPVIS_DEFINITIONS /wd4290 /wd4390)
schultezub's avatar
schultezub committed
83
84
    
    # enable parallel builds in Visual Studio
schultezub's avatar
schultezub committed
85
    LIST(APPEND CAMPVIS_DEFINITIONS /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 CAMPVIS_DEFINITIONS /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 CAMPVIS_DEFINITIONS "-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 CAMPVIS_EXTERNAL_LIBRARIES netapi32 version)
115
    
schultezub's avatar
schultezub committed
116
ELSEIF(UNIX)
schultezub's avatar
schultezub committed
117
118
    LIST(APPEND CAMPVIS_DEFINITIONS "-DUNIX")  
    LIST(APPEND CAMPVIS_DEFINITIONS "-D__STDC_CONSTANT_MACROS")  
schultezub's avatar
schultezub committed
119
120
121
ENDIF(WIN32)

# tgt configuration
schultezub's avatar
schultezub committed
122
LIST(APPEND CAMPVIS_DEFINITIONS "-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
127
IF(CAMPVIS_DEBUG)
    LIST(APPEND CAMPVIS_DEFINITIONS -DTGT_DEBUG -DCAMPVIS_DEBUG)
schultezub's avatar
schultezub committed
128
129
130
ENDIF()
 
# minimum Qt version
schultezub's avatar
schultezub committed
131
SET(CAMPVIS_REQUIRED_QT_VERSION "4.8")
schultezub's avatar
schultezub committed
132
133
134
135
136
137


# detect libraries
MESSAGE(STATUS "--------------------------------------------------------------------------------")
MESSAGE(STATUS "Detecting Common Mandatory Libraries:")

schultezub's avatar
schultezub committed
138
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CAMPVIS_HOME}/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 CAMPVIS_INCLUDE_DIRECTORIES ${OPENGL_INCLUDE_DIR})
    LIST(APPEND CAMPVIS_EXTERNAL_LIBRARIES ${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 CAMPVIS_DEFINITIONS ${GLEW_DEFINITIONS})
    LIST(APPEND CAMPVIS_INCLUDE_DIRECTORIES ${GLEW_INCLUDE_DIR})
    LIST(APPEND CAMPVIS_EXTERNAL_LIBRARIES ${GLEW_LIBRARY})
    LIST(APPEND CAMPVIS_EXTERNAL_DEBUG_DLLS ${GLEW_DLL_DEBUG})
    LIST(APPEND CAMPVIS_EXTERNAL_RELEASE_DLLS ${GLEW_DLL_RELEASE})
    LIST(APPEND CAMPVIS_EXTERNAL_LICENSE_FILES ${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 CAMPVIS_DEFINITIONS ${TBB_DEFINITIONS})
    LIST(APPEND CAMPVIS_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIR})
    LIST(APPEND CAMPVIS_EXTERNAL_LIBRARIES ${TBB_LIBRARY})
    LIST(APPEND CAMPVIS_EXTERNAL_DEBUG_DLLS ${TBB_DLL_DEBUG})
    LIST(APPEND CAMPVIS_EXTERNAL_RELEASE_DLLS ${TBB_DLL_RELEASE})
    LIST(APPEND CAMPVIS_EXTERNAL_LICENSE_FILES ${TBB_LICENSE_FILE})
schultezub's avatar
schultezub committed
174
175
176
177
ELSE(TBB_FOUND)
    MESSAGE(FATAL_ERROR "TBB not found!")
ENDIF(TBB_FOUND)

178
179
180
# OpenCL
FIND_PACKAGE(CL REQUIRED)
    MESSAGE(STATUS "* Found OpenCL")
schultezub's avatar
schultezub committed
181
182
    LIST(APPEND CAMPVIS_INCLUDE_DIRECTORIES ${OPENCL_INCLUDE_DIR})
    LIST(APPEND CAMPVIS_EXTERNAL_LIBRARIES ${OPENCL_LIBRARY})
183
184
185
186
IF (OPENCL_FOUND)
ELSE(OPENCL_FOUND)
    MESSAGE(FATAL_ERROR "OpenCL not found!")
ENDIF(OPENCL_FOUND)
schultezub's avatar
schultezub committed
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

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

# collect list of directories in modules directories
SET(ModulesDir ${CAMPVIS_HOME}/modules)
LIST_SUBDIRECTORIES(ModDirs ${ModulesDir} false)

# remove CMake realted directories
LIST(REMOVE_ITEM ModDirs CMakeFiles)
LIST(REMOVE_ITEM ModDirs campvis-modules.dir)

# 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
            LIST(APPEND CAMPVisModulesDefinitions ${ThisModDefinitions})
            LIST(APPEND CAMPVisModulesIncludeDirs ${ThisModIncludeDirs})
            LIST(APPEND CAMPVisModulesExternalLibs ${ThisModExternalLibs})
            LIST(APPEND CAMPVisModulesSources ${ThisModSources})
            LIST(APPEND CAMPVisModulesHeaders ${ThisModHeaders})
            
            # 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
242
243
SET(COMMONCONF_PROCESSED TRUE)
ENDIF(NOT COMMONCONF_PROCESSED)