fix for building with msvc/cmake take 2 (think its correct this time)
authorCampbell Barton <ideasman42@gmail.com>
Sun, 26 Jun 2011 17:18:37 +0000 (17:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 26 Jun 2011 17:18:37 +0000 (17:18 +0000)
also sync build flags with scons.

CMakeLists.txt
build_files/cmake/macros.cmake

index a92041c..d65e62d 100644 (file)
@@ -544,13 +544,13 @@ elseif(WIN32)
 
        if(MSVC)
                if(CMAKE_CL_64)
-                       set(LLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid )
+                       set(LLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
                else()
-                       set(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
+                       set(LLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
                endif()
                
-               set(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
-               set(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
+               set(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB /nologo /Ob1 /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013" CACHE STRING "MSVC MT C++ flags " FORCE)
+               set(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB /nologo /Ob1 /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
 
                if(CMAKE_CL_64)
                        set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
@@ -695,9 +695,9 @@ elseif(WIN32)
 
                # MSVC only, Mingw doesnt need
                if(CMAKE_CL_64)
-                       set(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib /STACK:2097152 ")
+                       set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /MACHINE:X64 /STACK:2097152 /OPT:NOREF /INCREMENTAL:NO /NODEFAULTLIB:\"msvcrt.lib\" /NODEFAULTLIB:\"msvcmrt.lib\" /NODEFAULTLIB:\"msvcurt.lib\" /NODEFAULTLIB:\"msvcrtd.lib\" ")
                else()
-                       set(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib /STACK:2097152 ")
+                       set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /MACHINE:IX86 /STACK:2097152 /INCREMENTAL:NO /LARGEADDRESSAWARE /NODEFAULTLIB:\"msvcrt.lib\" /NODEFAULTLIB:\"msvcmrt.lib\" /NODEFAULTLIB:\"msvcurt.lib\" /NODEFAULTLIB:\"msvcrtd.lib\" ")
                endif()
 
                set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
index 1800c4e..8ae7345 100644 (file)
@@ -39,6 +39,21 @@ macro(file_list_suffix
 
 endmacro()
 
+
+macro(target_link_libraries_optimized TARGET LIBS)
+       foreach(_LIB ${LIBS})
+               target_link_libraries(${TARGET} optimized "${_LIB}")
+       endforeach()
+       unset(_LIB)
+endmacro()
+
+macro(target_link_libraries_debug TARGET LIBS)
+       foreach(_LIB ${LIBS})
+               target_link_libraries(${TARGET} debug "${_LIB}")
+       endforeach()
+       unset(_LIB)
+endmacro()
+
 # Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
 # use it instead of include_directories()
 macro(blender_include_dirs
@@ -202,8 +217,8 @@ macro(setup_liblinks
 
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
-                       target_link_libraries(${target} debug ${PYTHON_LIBRARIES_DEBUG})
-                       target_link_libraries(${target} optimized ${PYTHON_LIBRARIES})
+                       target_link_libraries_debug(${target} "${PYTHON_LIBRARIES_DEBUG}")
+                       target_link_libraries_optimized(${target} "${PYTHON_LIBRARIES}")
                        unset(PYTHON_LIBRARIES_DEBUG)
                else()
                        target_link_libraries(${target} ${PYTHON_LIBRARIES})
@@ -256,8 +271,8 @@ macro(setup_liblinks
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
-                       target_link_libraries(${target} debug ${OPENEXR_LIBRARIES_DEBUG})
-                       target_link_libraries(${target} optimized ${OPENEXR_LIBRARIES})
+                       target_link_libraries_debug(${target} "${OPENEXR_LIBRARIES_DEBUG}")
+                       target_link_libraries_optimized(${target} "${OPENEXR_LIBRARIES}")
                        unset(OPENEXR_LIBRARIES_DEBUG)
                else()
                        target_link_libraries(${target} ${OPENEXR_LIBRARIES})
@@ -272,19 +287,19 @@ macro(setup_liblinks
        if(WITH_OPENCOLLADA)
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d")
-                       target_link_libraries(${target} debug ${OPENCOLLADA_LIBRARIES_DEBUG})
-                       target_link_libraries(${target} optimized ${OPENCOLLADA_LIBRARIES})
+                       target_link_libraries_debug(${target} "${OPENCOLLADA_LIBRARIES_DEBUG}")
+                       target_link_libraries_optimized(${target} "${OPENCOLLADA_LIBRARIES}")
                        unset(OPENCOLLADA_LIBRARIES_DEBUG)
 
                        file_list_suffix(PCRE_LIB_DEBUG "${PCRE_LIB}" "_d")
-                       target_link_libraries(${target} debug ${PCRE_LIB_DEBUG})
-                       target_link_libraries(${target} optimized ${PCRE_LIB})
+                       target_link_libraries_debug(${target} "${PCRE_LIB_DEBUG}")
+                       target_link_libraries_optimized(${target} "${PCRE_LIB}")
                        unset(PCRE_LIB_DEBUG)
 
                        if(EXPAT_LIB)
                                file_list_suffix(EXPAT_LIB_DEBUG "${EXPAT_LIB}" "_d")
-                               target_link_libraries(${target} debug ${EXPAT_LIB_DEBUG})
-                               target_link_libraries(${target} optimized ${EXPAT_LIB})
+                               target_link_libraries_debug(${target} "${EXPAT_LIB_DEBUG}")
+                               target_link_libraries_optimized(${target} "${EXPAT_LIB}")
                                unset(EXPAT_LIB_DEBUG)
                        endif()
                else()