2 MESSAGE(STATUS "Applying Compiler Defaults")
4 SET(OSG_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DOSG_DEBUG")
5 SET(OSG_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DOSG_DEBUG")
8 SET(OSG_CXX_FLAGS_DEBUG "${OSG_CXX_FLAGS_DEBUG} -D_DEBUG")
9 SET(OSG_C_FLAGS_DEBUG "${OSG_C_FLAGS_DEBUG} -D_DEBUG")
13 SET(OSG_CXX_FLAGS_DEBUG "${OSG_CXX_FLAGS_DEBUG} -g")
14 SET(OSG_C_FLAGS_DEBUG "${OSG_C_FLAGS_DEBUG} -g")
17 SET(OSG_CXX_FLAGS ${CMAKE_CXX_FLAGS})
18 SET(OSG_C_FLAGS ${CMAKE_C_FLAGS})
20 SET(OSG_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
21 SET(OSG_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
24 SET(OSG_CXX_FLAGS_RELEASE "${OSG_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
25 SET(OSG_C_FLAGS_RELEASE "${OSG_C_FLAGS_RELEASE} -O3 -DNDEBUG")
28 SET(OSG_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
29 SET(OSG_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
33 MESSAGE(STATUS "Setup MSVC")
35 # Hide unused cmake targets
37 SET(CMAKE_CXX_FLAGS_MINSIZEREL
38 "${CMAKE_CXX_FLAGS_MINSIZEREL}"
41 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
42 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
46 SET(CMAKE_C_FLAGS_MINSIZEREL
47 "${CMAKE_C_FLAGS_MINSIZEREL}"
50 SET(CMAKE_C_FLAGS_RELWITHDEBINFO
51 "${CMAKE_C_FLAGS_RELWITHDEBINFO}"
57 SET(OSG_CXX_FLAGS_RELEASENOOPT "${OSG_CXX_FLAGS_DEBUG} /MP${OSG_NUM_COMPILE_PROC}")
58 SET(OSG_C_FLAGS_RELEASENOOPT "${OSG_C_FLAGS_DEBUG} /MP${OSG_NUM_COMPILE_PROC}")
60 STRING(REPLACE "MDd" "MD" OSG_CXX_FLAGS_RELEASENOOPT ${OSG_CXX_FLAGS_RELEASENOOPT})
61 STRING(REPLACE "MDd" "MD" OSG_C_FLAGS_RELEASENOOPT ${OSG_C_FLAGS_RELEASENOOPT})
63 STRING(REPLACE "/RTC1" "" OSG_CXX_FLAGS_RELEASENOOPT ${OSG_CXX_FLAGS_RELEASENOOPT})
64 STRING(REPLACE "/RTC1" "" OSG_C_FLAGS_RELEASENOOPT ${OSG_C_FLAGS_RELEASENOOPT})
66 STRING(REPLACE "/D_DEBUG" "" OSG_CXX_FLAGS_RELEASENOOPT ${OSG_CXX_FLAGS_RELEASENOOPT})
67 STRING(REPLACE "/D_DEBUG" "" OSG_C_FLAGS_RELEASENOOPT ${OSG_C_FLAGS_RELEASENOOPT})
71 SET(OSG_CXX_FLAGS_DEBUG "${OSG_CXX_FLAGS_DEBUG} -DOSG_DEBUGRT /MP${OSG_NUM_COMPILE_PROC}")
72 SET(OSG_C_FLAGS_DEBUG "${OSG_C_FLAGS_DEBUG} -DOSG_DEBUGRT /MP${OSG_NUM_COMPILE_PROC}")
76 SET(OSG_CXX_FLAGS_DEBUGOPT "${OSG_CXX_FLAGS_RELEASE} -DOSG_DEBUGRT /Zi /MP${OSG_NUM_COMPILE_PROC}")
77 SET(OSG_C_FLAGS_DEBUGOPT "${OSG_C_FLAGS_RELEASE} -DOSG_DEBUGRT /Zi /MP${OSG_NUM_COMPILE_PROC}")
79 STRING(REPLACE "MD" "MDd" OSG_CXX_FLAGS_DEBUGOPT ${OSG_CXX_FLAGS_DEBUGOPT})
80 STRING(REPLACE "MD" "MDd" OSG_C_FLAGS_DEBUGOPT ${OSG_C_FLAGS_DEBUGOPT})
82 # STRING(REPLACE "/D NDEBUG " "" OSG_CXX_FLAGS_DEBUGOPT ${OSG_CXX_FLAGS_DEBUGOPT})
83 # STRING(REPLACE "/D NDEBUG " "" OSG_C_FLAGS_DEBUGOPT ${OSG_C_FLAGS_DEBUGOPT})
87 SET(OSG_CXX_FLAGS_RELEASE "${OSG_CXX_FLAGS_RELEASE} /Zi /MP${OSG_NUM_COMPILE_PROC}")
88 SET(OSG_C_FLAGS_RELEASE "${OSG_C_FLAGS_RELEASE} /Zi /MP${OSG_NUM_COMPILE_PROC}")
92 SET(CMAKE_CXX_FLAGS_DEBUGOPT
93 "${OSG_CXX_FLAGS_DEBUGOPT}"
94 CACHE STRING "Flags used by the C++ compiler during maintainer builds."
97 SET(CMAKE_C_FLAGS_DEBUGOPT
98 "${OSG_C_FLAGS_DEBUGOPT}"
99 CACHE STRING "Flags used by the C compiler during maintainer builds."
102 SET(CMAKE_CXX_FLAGS_RELEASENOOPT
103 "${OSG_CXX_FLAGS_RELEASENOOPT}"
104 CACHE STRING "Flags used by the C++ compiler during maintainer builds."
107 SET(CMAKE_C_FLAGS_RELEASENOOPT
108 "${OSG_C_FLAGS_RELEASENOOPT}"
109 CACHE STRING "Flags used by the C compiler during maintainer builds."
117 # STRING(REPLACE "W3" "W1" OSG_CXX_FLAGS ${OSG_CXX_FLAGS})
118 # STRING(REPLACE "W3" "W1" OSG_C_FLAGS ${OSG_C_FLAGS})
120 # 4290 exception spec
122 # 4275 derived from not exported
123 # 4661 template class mem func not defined
124 # 4351 member init array handling
126 # 4231 non standard ext
128 # 4244 smaller type assign
129 # 4355 this before constructed
133 STRING(REPLACE "W3" "W3 /wd4244 /wd4290 /wd4251 /wd4275 /wd4661 /wd4351 /wd4996 /wd4231" OSG_CXX_FLAGS ${OSG_CXX_FLAGS})
134 STRING(REPLACE "W3" "W3 /wd4244 /wd4290 /wd4251 /wd4275 /wd4351 /wd4996" OSG_C_FLAGS ${OSG_C_FLAGS})
136 SET(OSG_CXX_FLAGS "/bigobj ${OSG_CXX_FLAGS} /D_WIN32_WINNT=0x0500 /DWINVER=0x0500")
137 SET(OSG_C_FLAGS "/bigobj ${OSG_C_FLAGS} /D_WIN32_WINNT=0x0500 /DWINVER=0x0500")
142 SET(OSG_EXE_LINKER_FLAGS "${OSG_EXE_LINKER_FLAGS} /nodefaultlib")
143 SET(OSG_SHARED_LINKER_FLAGS "${OSG_SHARED_LINKER_FLAGS} /nodefaultlib")
145 SET(OSG_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} winmm.lib wsock32.lib oldnames.lib")
146 SET(OSG_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} winmm.lib wsock32.lib oldnames.lib")
148 SET(OSG_CLEAR_STD_LIBS winspool.lib shell32.lib ole32.lib oleaut32.lib
149 uuid.lib comdlg32.lib msvcprt.lib msvcrt.lib)
151 FOREACH(STD_LIB ${OSG_CLEAR_STD_LIBS})
152 STRING(REPLACE ${STD_LIB} "" OSG_CXX_STANDARD_LIBRARIES ${OSG_CXX_STANDARD_LIBRARIES})
153 STRING(REPLACE ${STD_LIB} "" OSG_C_STANDARD_LIBRARIES ${OSG_C_STANDARD_LIBRARIES})
156 SET(CMAKE_CXX_STANDARD_LIBRARIES ${OSG_CXX_STANDARD_LIBRARIES}
157 CACHE STRING "OpenSG defaults" FORCE )
158 SET(CMAKE_C_STANDARD_LIBRARIES ${OSG_C_STANDARD_LIBRARIES}
159 CACHE STRING "OpenSG defaults" FORCE )
161 # SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo;DebugRT"
162 # CACHE STRING "OpenSG Build Types" FORCE )
164 SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugOpt;ReleaseNoOpt"
165 CACHE STRING "OpenSG Build Types" FORCE )
169 # Shared Linker Flags
171 SET(CMAKE_SHARED_LINKER_FLAGS_RELEASENOOPT
172 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} msvcprt.lib msvcrt.lib"
173 CACHE STRING "OpenSG defaults" FORCE )
175 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPT
176 "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /debug msvcprtd.lib msvcrtd.lib"
177 CACHE STRING "OpenSG defaults" FORCE )
179 SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE
180 "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /debug msvcprt.lib msvcrt.lib"
181 CACHE STRING "OpenSG defaults" FORCE )
183 SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
184 "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} msvcprt.lib msvcrt.lib"
185 CACHE INTERNAL "OpenSG defaults" FORCE )
187 SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
188 "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} msvcprt.lib msvcrt.lib"
189 CACHE INTERNAL "OpenSG defaults" FORCE )
191 STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
192 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
194 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG
195 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} msvcprtd.lib msvcrtd.lib"
196 CACHE STRING "OpenSG defaults" FORCE )
200 SET(CMAKE_EXE_LINKER_FLAGS_RELEASENOOPT
201 "${CMAKE_EXE_LINKER_FLAGS_DEBUG} msvcprt.lib msvcrt.lib"
202 CACHE STRING "OpenSG defaults" FORCE )
204 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG
205 "${CMAKE_EXE_LINKER_FLAGS_DEBUG} msvcprtd.lib msvcrtd.lib"
206 CACHE STRING "OpenSG defaults" FORCE )
208 SET(CMAKE_EXE_LINKER_FLAGS_DEBUGOPT
209 "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug msvcprtd.lib msvcrtd.lib"
210 CACHE STRING "OpenSG defaults" FORCE )
212 SET(CMAKE_EXE_LINKER_FLAGS_RELEASE
213 "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug msvcprt.lib msvcrt.lib"
214 CACHE STRING "OpenSG defaults" FORCE )
217 SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
218 "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} msvcprt.lib msvcrt.lib"
219 CACHE INTERNAL "OpenSG defaults" FORCE )
221 SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
222 "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} msvcprt.lib msvcrt.lib"
223 CACHE INTERNAL "OpenSG defaults" FORCE )
228 SET(CMAKE_MODULE_LINKER_FLAGS
229 "${CMAKE_MODULE_LINKER_FLAGS}"
230 CACHE INTERNAL "OpenSG defaults" FORCE )
232 SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG
233 "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}"
234 CACHE INTERNAL "OpenSG defaults" FORCE )
236 SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
237 "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL}"
238 CACHE INTERNAL "OpenSG defaults" FORCE )
240 SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE
241 "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}"
242 CACHE INTERNAL "OpenSG defaults" FORCE )
244 SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
245 "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO}"
246 CACHE INTERNAL "OpenSG defaults" FORCE )
251 IF(CMAKE_COMPILER_IS_GNUCC)
253 IF(OSG_PLATFORM_64 AND LINUX)
254 SET(OSG_CXX_FLAGS "${OSG_CXX_FLAGS} -m64")
255 SET(OSG_C_FLAGS "${OSG_C_FLAGS} -m64")
257 SET(OSG_EXE_LINKER_FLAGS "${OSG_EXE_LINKER_FLAGS} -m64")
258 SET(OSG_SHARED_LINKER_FLAGS "${OSG_SHARED_LINKER_FLAGS} -m64")
260 ENDIF(OSG_PLATFORM_64 AND LINUX)
262 SET(OSG_CXX_FLAGS "${OSG_CXX_FLAGS} -D__STDC_FORMAT_MACROS -fPIC")
263 SET(OSG_C_FLAGS "${OSG_C_FLAGS} -D__STDC_FORMAT_MACROS -fPIC")
265 ENDIF(CMAKE_COMPILER_IS_GNUCC)
272 SET(CMAKE_CXX_FLAGS ${OSG_CXX_FLAGS}
273 CACHE STRING "OpenSG defaults" FORCE )
274 SET(CMAKE_C_FLAGS ${OSG_C_FLAGS}
275 CACHE STRING "OpenSG defaults" FORCE )
277 SET(CMAKE_CXX_FLAGS_DEBUG ${OSG_CXX_FLAGS_DEBUG}
278 CACHE STRING "OpenSG defaults" FORCE )
279 SET(CMAKE_C_FLAGS_DEBUG ${OSG_C_FLAGS_DEBUG}
280 CACHE STRING "OpenSG defaults" FORCE )
282 SET(CMAKE_CXX_FLAGS_RELEASE ${OSG_CXX_FLAGS_RELEASE}
283 CACHE STRING "OpenSG defaults" FORCE )
284 SET(CMAKE_C_FLAGS_RELEASE ${OSG_C_FLAGS_RELEASE}
285 CACHE STRING "OpenSG defaults" FORCE )
288 SET(CMAKE_EXE_LINKER_FLAGS ${OSG_EXE_LINKER_FLAGS}
289 CACHE STRING "OpenSG defaults" FORCE )
290 SET(CMAKE_SHARED_LINKER_FLAGS ${OSG_SHARED_LINKER_FLAGS}
291 CACHE STRING "OpenSG defaults" FORCE )
299 IF(CMAKE_COMPILER_IS_GNUCC)
300 # SET(OSG_CXX_FLAGS_GV " -Wall -Wextra -Wreturn-type -Wold-style-cast -DOSG_DEBUG_OLD_C_CASTS -DOSG_CLEAN_FCFIELDS -DOSG_CHECK_CONST_CORRECT_FIELD_USAGE -Wwrite-strings -Werror -Wno-unused-parameter")
302 SET(OSG_CXX_FLAGS_GV " -Wall -Wreturn-type -Wold-style-cast -DOSG_DEBUG_OLD_C_CASTS -DOSG_CLEAN_FCFIELDS -DOSG_CHECK_CONST_CORRECT_FIELD_USAGE -Wwrite-strings -Werror -Wno-unused-parameter")
304 # SET(OSG_C_FLAGS_GV " -Wall -Wextra -Wreturn-type -Wold-style-cast -DOSG_DEBUG_OLD_C_CASTS -DOSG_CLEAN_FCFIELDS -DOSG_CHECK_CONST_CORRECT_FIELD_USAGE -Wwrite-strings -Werror -Wno-unused-parameter")
305 SET(OSG_C_FLAGS_GV " -Wall -Wextra -Wreturn-type -Wold-style-cast -DOSG_DEBUG_OLD_C_CASTS -DOSG_CLEAN_FCFIELDS -DOSG_CHECK_CONST_CORRECT_FIELD_USAGE -Wwrite-strings -Werror -Wno-unused-parameter")
308 SET(OSG_ADD_CXX_FLAGS_GV "")
309 SET(OSG_ADD_C_FLAGS_GV "")
311 SET(OSG_SHARED_LINKER_FLAGS_GV " -Wl,--no-undefined")
318 SET(CMAKE_CXX_FLAGS_DEBUGGV
319 "${CMAKE_CXX_FLAGS_DEBUG}${OSG_CXX_FLAGS_GV}"
320 CACHE STRING "Flags used by the C++ compiler during maintainer builds."
323 SET(CMAKE_C_FLAGS_DEBUGGV
324 "${CMAKE_C_FLAGS_DEBUG}${OSG_C_FLAGS_GV}"
325 CACHE STRING "Flags used by the C compiler during maintainer builds."
328 SET(CMAKE_EXE_LINKER_FLAGS_DEBUGGV
329 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}"
330 CACHE STRING "Flags used for linking binaries during maintainer builds."
333 SET(CMAKE_MODULE_LINKER_FLAGS_DEBUGGV
334 "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}"
335 CACHE STRING "Flags used for linking binaries during maintainer builds."
338 SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGGV
339 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}${OSG_SHARED_LINKER_FLAGS_GV}"
341 "Flags used by the shared libraries linker during maintainer builds."
348 SET(CMAKE_CXX_FLAGS_RELEASEGV
349 "${CMAKE_CXX_FLAGS_RELEASE}${OSG_CXX_FLAGS_GV}"
350 CACHE STRING "Flags used by the C++ compiler during gv builds."
353 SET(CMAKE_C_FLAGS_RELEASEGV
354 "${CMAKE_C_FLAGS_RELEASE}${OSG_C_FLAGS_GV}"
355 CACHE STRING "Flags used by the C compiler during gv builds."
358 SET(CMAKE_EXE_LINKER_FLAGS_RELEASEGV
359 "${CMAKE_EXE_LINKER_FLAGS_RELEASE}"
360 CACHE STRING "Flags used for linking binaries during gv builds."
363 SET(CMAKE_MODULE_LINKER_FLAGS_RELEASEGV
364 "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}"
365 CACHE STRING "Flags used for linking binaries during gv builds."
368 SET(CMAKE_SHARED_LINKER_FLAGS_RELEASEGV
369 "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}${OSG_SHARED_LINKER_FLAGS_GV}"
371 "Flags used by the shared libraries linker during gv builds."
374 ENDIF(CMAKE_COMPILER_IS_GNUCC)