From a34903aa3302a571b2fbfc9df3aa5c0a817c76dc Mon Sep 17 00:00:00 2001 From: Gregory Popovitch Date: Mon, 23 Sep 2019 13:15:34 -0400 Subject: [PATCH] Update CMake configuration to support building with MSVC --- .gitignore | 2 + CMakeLists.txt | 91 ++++++++++++++++-------- filament/CMakeLists.txt | 18 +++-- filament/backend/CMakeLists.txt | 18 +++-- libs/filagui/CMakeLists.txt | 10 +-- libs/filamat/CMakeLists.txt | 6 +- libs/geometry/CMakeLists.txt | 4 +- libs/gltfio/CMakeLists.txt | 4 +- libs/image/CMakeLists.txt | 4 +- libs/imageio/CMakeLists.txt | 4 +- libs/rays/CMakeLists.txt | 5 +- samples/CMakeLists.txt | 8 ++- third_party/astcenc/tnt/CMakeLists.txt | 4 +- third_party/benchmark/CMakeLists.txt | 52 +++++++------- third_party/benchmark/tnt/CMakeLists.txt | 8 ++- third_party/libassimp/tnt/CMakeLists.txt | 38 +++++----- third_party/libgtest/tnt/CMakeLists.txt | 6 ++ third_party/libsdl2/tnt/CMakeLists.txt | 32 +++++---- third_party/libz/tnt/CMakeLists.txt | 10 +-- third_party/smol-v/tnt/CMakeLists.txt | 5 +- third_party/tinyexr/tnt/CMakeLists.txt | 2 +- tools/cmgen/CMakeLists.txt | 4 ++ tools/filamesh/CMakeLists.txt | 14 ++-- 23 files changed, 219 insertions(+), 130 deletions(-) diff --git a/.gitignore b/.gitignore index 617887ef52..9e532a474b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ filament/docs/html/** gltf_baker.ini *tmp*.png civetweb.txt +/out* +/TAGS diff --git a/CMakeLists.txt b/CMakeLists.txt index 23975fe5dd..8374b20112 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,19 +50,22 @@ if (WIN32) set(CRT_FLAGS_DEBUG "/MDd") endif() - # TODO: Figure out why pdb generation messes with incremental compilaton. - # IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb. - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7") + if (CMAKE_C_COMPILER_ID MATCHES "Clang") + # TODO: Figure out why pdb generation messes with incremental compilaton. + # IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb. + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7") + + # In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation. + # Instead generate debug info directly inside obj files. + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7") + endif() # In RELEASE, also generate PDBs. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi") - # In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation. - # Instead generate debug info directly inside obj files. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7") endif() # ================================================================================================== @@ -113,7 +116,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang") if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION) message(FATAL_ERROR "Detected C compiler Clang ${CMAKE_C_COMPILER_VERSION} < ${MIN_CLANG_VERSION}") endif() -else() +elseif (NOT MSVC) message(FATAL_ERROR "Detected C compiler ${CMAKE_C_COMPILER_ID} is unsupported") endif() @@ -121,13 +124,17 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION) message(FATAL_ERROR "Detected CXX compiler Clang ${CMAKE_CXX_COMPILER_VERSION} < ${MIN_CLANG_VERSION}") endif() -else() +elseif (NOT MSVC) message(FATAL_ERROR "Detected CXX compiler ${CMAKE_CXX_COMPILER_ID} is unsupported") endif() # Detect use of the clang-cl.exe frontend, which does not support all of clangs normal options -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - set(CLANG_CL true) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + set(CLANG_CL true) + endif() +elseif (MSVC) + set(MSVC_NATIVE true) endif() # ================================================================================================== @@ -152,7 +159,12 @@ if (WIN32) set(CXX_STANDARD "/std:c++14") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function") +if (MSVC_NATIVE) + set(CXX_STANDARD "/std:c++latest") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /W0 /Zc:__cplusplus") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function") +endif() if (USE_EXTERNAL_GLES3) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_EXTERNAL_GLES3") @@ -173,7 +185,7 @@ if (CYGWIN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti") endif() -if (CLANG_CL) +if (CLANG_CL OR MSVC) # Since the "secure" replacements that MSVC suggests are not portable, disable # the deprecation warnings. Also disable warnings about use of POSIX functions (i.e. "unlink"). set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE") @@ -189,7 +201,7 @@ endif() # ================================================================================================== # Release compiler flags # ================================================================================================== -if (NOT CLANG_CL) +if (NOT CLANG_CL AND NOT MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections") endif() @@ -207,7 +219,7 @@ endif() # -fsanitize=address causes a crash with assimp, which we can't explain for now #set(EXTRA_SANITIZE_OPTIONS "-fsanitize=undefined -fsanitize=address") # clang-cl.exe on Windows does not support -fstack-protector. -if (NOT CLANG_CL) +if (NOT CLANG_CL AND NOT MSVC) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector") endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}") @@ -324,20 +336,39 @@ endif() # ================================================================================================== # Functions # ================================================================================================== -function(list_licenses OUTPUT MODULES) - set(CONTENT) - set(_MODULES ${MODULES} ${ARGN}) - foreach(module ${_MODULES}) - set(license_path "../../third_party/${module}/LICENSE") - get_filename_component(fullname "${license_path}" ABSOLUTE) - string(APPEND CONTENT "License and copyrights for ${module}:\n\n") - file(READ ${license_path} license) - string(APPEND CONTENT ${license}) - string(APPEND CONTENT "\n\n") - endforeach() - configure_file(${FILAMENT}/build/licenses.inc.in ${OUTPUT}) -endfunction(list_licenses) - +if (MSVC_NATIVE) + ## The MSVC compiler has a limitation on literal string length which is reached when all the + ## licenses are concatenated together into a large string... so split them into multiple strings. + function(list_licenses OUTPUT MODULES) + file(WRITE ${OUTPUT} " R\"FILAMENT__(") + set(_MODULES ${MODULES} ${ARGN}) + foreach(module ${_MODULES}) + set(license_path "../../third_party/${module}/LICENSE") + get_filename_component(fullname "${license_path}" ABSOLUTE) + file(APPEND ${OUTPUT} ")FILAMENT__\", \nR\"FILAMENT__(License and copyrights for ${module}:\n\n)FILAMENT__\", \nR\"FILAMENT__(") + file(READ ${license_path} license_long) + string(REPLACE "\n" ")FILAMENT__\", \nR\"FILAMENT__(" license ${license_long}) + file(APPEND ${OUTPUT} ${license}) + file(APPEND ${OUTPUT} ")FILAMENT__\", \nR\"FILAMENT__(\n\n)FILAMENT__\", \"") + endforeach() + file(APPEND ${OUTPUT} "\"") + #file(APPEND ${OUTPUT} ")FILAMENT__\"\n") + endfunction(list_licenses) +else() + function(list_licenses OUTPUT MODULES) + set(CONTENT) + set(_MODULES ${MODULES} ${ARGN}) + foreach(module ${_MODULES}) + set(license_path "../../third_party/${module}/LICENSE") + get_filename_component(fullname "${license_path}" ABSOLUTE) + string(APPEND CONTENT "License and copyrights for ${module}:\n\n") + file(READ ${license_path} license) + string(APPEND CONTENT ${license}) + string(APPEND CONTENT "\n\n") + endforeach() + configure_file(${FILAMENT}/build/licenses.inc.in ${OUTPUT}) + endfunction(list_licenses) +endif() # ================================================================================================== # Configuration for CMAKE_CROSSCOMPILING. # ================================================================================================== diff --git a/filament/CMakeLists.txt b/filament/CMakeLists.txt index e46d28368a..44c58e1193 100644 --- a/filament/CMakeLists.txt +++ b/filament/CMakeLists.txt @@ -327,13 +327,17 @@ set(LINUX_COMPILER_FLAGS -fPIC ) -set(FILAMENT_WARNINGS - -Wextra -Wno-unused-parameter - -Wextra-semi -Wnewline-eof -Wdeprecated -Wundef - -Wgnu-conditional-omitted-operand - -Wweak-vtables -Wnon-virtual-dtor -Wclass-varargs -Wimplicit-fallthrough - -Wover-aligned -) +if (MSVC_NATIVE) + set(FILAMENT_WARNINGS -W0) +else() + set(FILAMENT_WARNINGS + -Wextra -Wno-unused-parameter + -Wextra-semi -Wnewline-eof -Wdeprecated -Wundef + -Wgnu-conditional-omitted-operand + -Wweak-vtables -Wnon-virtual-dtor -Wclass-varargs -Wimplicit-fallthrough + -Wover-aligned + ) +endif() # clang-cl maps -Wall to -Weverything, which clutters logs with benign -Wc++98-compat warnings # Use /W4 instead for clang-cl builds diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt index 829f8e9066..693fd0c5b9 100644 --- a/filament/backend/CMakeLists.txt +++ b/filament/backend/CMakeLists.txt @@ -235,13 +235,17 @@ set(LINUX_COMPILER_FLAGS -fPIC ) -set(FILAMENT_WARNINGS - -Wextra -Wno-unused-parameter - -Wextra-semi -Wnewline-eof -Wdeprecated -Wundef - -Wgnu-conditional-omitted-operand - -Wweak-vtables -Wnon-virtual-dtor -Wclass-varargs -Wimplicit-fallthrough - -Wover-aligned -) +if (NOT MSVC_NATIVE) + set(FILAMENT_WARNINGS + -Wextra -Wno-unused-parameter + -Wextra-semi -Wnewline-eof -Wdeprecated -Wundef + -Wgnu-conditional-omitted-operand + -Wweak-vtables -Wnon-virtual-dtor -Wclass-varargs -Wimplicit-fallthrough + -Wover-aligned + ) +else() + set(FILAMENT_WARNINGS /W0) +endif() # clang-cl maps -Wall to -Weverything, which clutters logs with benign -Wc++98-compat warnings # Use /W4 instead for clang-cl builds diff --git a/libs/filagui/CMakeLists.txt b/libs/filagui/CMakeLists.txt index 7b41eaff5b..d4af766603 100644 --- a/libs/filagui/CMakeLists.txt +++ b/libs/filagui/CMakeLists.txt @@ -87,7 +87,9 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) # ================================================================================================== # Compiler flags # ================================================================================================== -target_compile_options(${TARGET} PRIVATE - -Wno-deprecated-register - $<$:-ffast-math> -) +if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE + -Wno-deprecated-register + $<$:-ffast-math> + ) +endif() diff --git a/libs/filamat/CMakeLists.txt b/libs/filamat/CMakeLists.txt index 578d416a5f..c118b8fdd4 100644 --- a/libs/filamat/CMakeLists.txt +++ b/libs/filamat/CMakeLists.txt @@ -98,7 +98,7 @@ target_include_directories(${TARGET} PRIVATE ${spirv-tools_SOURCE_DIR}/include) # glslang libraries have circular dependencies. To make sure the proper object are part of the link # we need to force archive re-scan on new symbol dependencies via start/end-group. # Read more about this here https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking -if (APPLE) +if (APPLE OR MSVC_NATIVE) target_link_libraries(${TARGET} glslang SPIRV SPVRemapper SPIRV-Tools-opt spirv-cross-glsl) else() target_link_libraries(${TARGET} @@ -125,6 +125,10 @@ target_compile_options(filamat_lite PRIVATE target_compile_definitions(filamat_lite PRIVATE FILAMAT_LITE) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /Zc:__cplusplus") +endif() + # ================================================================================================== # Installation # ================================================================================================== diff --git a/libs/geometry/CMakeLists.txt b/libs/geometry/CMakeLists.txt index cd72cc80e8..8adc96d4ad 100644 --- a/libs/geometry/CMakeLists.txt +++ b/libs/geometry/CMakeLists.txt @@ -29,7 +29,9 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) # ================================================================================================== # Compiler flags # ================================================================================================== -target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +endif() if (MSVC OR CLANG_CL) target_compile_options(${TARGET} PRIVATE $<$:/fp:fast>) diff --git a/libs/gltfio/CMakeLists.txt b/libs/gltfio/CMakeLists.txt index 38bb0b6734..33584bfe8a 100644 --- a/libs/gltfio/CMakeLists.txt +++ b/libs/gltfio/CMakeLists.txt @@ -120,7 +120,9 @@ if (NOT WEBGL AND NOT ANDROID AND NOT IOS) # ================================================================================================== # Compiler flags # ================================================================================================== - target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) + if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) + endif() if (MSVC OR CLANG_CL) target_compile_options(${TARGET} PRIVATE $<$:/fp:fast>) diff --git a/libs/image/CMakeLists.txt b/libs/image/CMakeLists.txt index 9949e11537..2bb339e065 100644 --- a/libs/image/CMakeLists.txt +++ b/libs/image/CMakeLists.txt @@ -37,7 +37,9 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) # ================================================================================================== # Compiler flags # ================================================================================================== -target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +endif() if (MSVC OR CLANG_CL) target_compile_options(${TARGET} PRIVATE $<$:/fp:fast>) diff --git a/libs/imageio/CMakeLists.txt b/libs/imageio/CMakeLists.txt index 1cb64c3ebf..e15559d85e 100644 --- a/libs/imageio/CMakeLists.txt +++ b/libs/imageio/CMakeLists.txt @@ -38,7 +38,9 @@ endif() # ================================================================================================== # Compiler flags # ================================================================================================== -target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +endif() if (MSVC OR CLANG_CL) target_compile_options(${TARGET} PRIVATE $<$:/fp:fast>) diff --git a/libs/rays/CMakeLists.txt b/libs/rays/CMakeLists.txt index cf45634659..7358098e9d 100644 --- a/libs/rays/CMakeLists.txt +++ b/libs/rays/CMakeLists.txt @@ -30,7 +30,10 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) # Compiler flags # ================================================================================================== -target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +if (NOT MSVC_NATIVE) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) +endif() + if (MSVC OR CLANG_CL) target_compile_options(${TARGET} PRIVATE $<$:/fp:fast>) else() diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 2d889fb881..fc6becd439 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -235,9 +235,11 @@ list(APPEND APP_LIBS sample-app) # Compiler flags # ================================================================================================== -set(COMPILER_FLAGS - -Wno-extern-c-compat - $<$>:-Wno-address-of-packed-member>) +if (NOT MSVC_NATIVE) + set(COMPILER_FLAGS + -Wno-extern-c-compat + $<$>:-Wno-address-of-packed-member>) +endif() if (MSVC OR CLANG_CL) set(COMPILER_FLAGS ${COMPILER_FLAGS} $<$:/fp:fast>) diff --git a/third_party/astcenc/tnt/CMakeLists.txt b/third_party/astcenc/tnt/CMakeLists.txt index 23bf23ba20..12f3d518f1 100644 --- a/third_party/astcenc/tnt/CMakeLists.txt +++ b/third_party/astcenc/tnt/CMakeLists.txt @@ -36,7 +36,9 @@ set(SOURCES ${SRCDIR}/softfloat.h ) -add_definitions(-Wno-tautological-compare) +if (NOT MSVC) + add_definitions(-Wno-tautological-compare) +endif() add_library(${TARGET} STATIC ${SOURCES}) diff --git a/third_party/benchmark/CMakeLists.txt b/third_party/benchmark/CMakeLists.txt index 310c7ee9f6..bda9b7de7c 100644 --- a/third_party/benchmark/CMakeLists.txt +++ b/third_party/benchmark/CMakeLists.txt @@ -134,31 +134,33 @@ else() endif() # Turn compiler warnings up to 11 - add_cxx_compiler_flag(-Wall) - add_cxx_compiler_flag(-Wextra) - add_cxx_compiler_flag(-Wshadow) - add_cxx_compiler_flag(-Werror RELEASE) - add_cxx_compiler_flag(-Werror RELWITHDEBINFO) - add_cxx_compiler_flag(-Werror MINSIZEREL) - add_cxx_compiler_flag(-pedantic) - add_cxx_compiler_flag(-pedantic-errors) - add_cxx_compiler_flag(-Wshorten-64-to-32) - add_cxx_compiler_flag(-fstrict-aliasing) - # Disable warnings regarding deprecated parts of the library while building - # and testing those parts of the library. - add_cxx_compiler_flag(-Wno-deprecated-declarations) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # Intel silently ignores '-Wno-deprecated-declarations', - # warning no. 1786 must be explicitly disabled. - # See #631 for rationale. - add_cxx_compiler_flag(-wd1786) - endif() - # Disable deprecation warnings for release builds (when -Werror is enabled). - add_cxx_compiler_flag(-Wno-deprecated RELEASE) - add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO) - add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL) - if (NOT BENCHMARK_ENABLE_EXCEPTIONS) - add_cxx_compiler_flag(-fno-exceptions) + if (NOT MSVC) + add_cxx_compiler_flag(-Wall) + add_cxx_compiler_flag(-Wextra) + add_cxx_compiler_flag(-Wshadow) + add_cxx_compiler_flag(-Werror RELEASE) + add_cxx_compiler_flag(-Werror RELWITHDEBINFO) + add_cxx_compiler_flag(-Werror MINSIZEREL) + add_cxx_compiler_flag(-pedantic) + add_cxx_compiler_flag(-pedantic-errors) + add_cxx_compiler_flag(-Wshorten-64-to-32) + add_cxx_compiler_flag(-fstrict-aliasing) + # Disable warnings regarding deprecated parts of the library while building + # and testing those parts of the library. + add_cxx_compiler_flag(-Wno-deprecated-declarations) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + # Intel silently ignores '-Wno-deprecated-declarations', + # warning no. 1786 must be explicitly disabled. + # See #631 for rationale. + add_cxx_compiler_flag(-wd1786) + endif() + # Disable deprecation warnings for release builds (when -Werror is enabled). + add_cxx_compiler_flag(-Wno-deprecated RELEASE) + add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO) + add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL) + if (NOT BENCHMARK_ENABLE_EXCEPTIONS) + add_cxx_compiler_flag(-fno-exceptions) + endif() endif() if (HAVE_CXX_FLAG_FSTRICT_ALIASING) diff --git a/third_party/benchmark/tnt/CMakeLists.txt b/third_party/benchmark/tnt/CMakeLists.txt index df08fb33fb..13d8e2d461 100644 --- a/third_party/benchmark/tnt/CMakeLists.txt +++ b/third_party/benchmark/tnt/CMakeLists.txt @@ -19,9 +19,11 @@ foreach(item ${BENCHMARK_MAIN}) list(REMOVE_ITEM SOURCE_FILES "${item}") endforeach() -add_definitions( - -Wno-deprecated-declarations -) +if (NOT MSVC) + add_definitions( + -Wno-deprecated-declarations + ) +endif() include_directories( ${PUBLIC_HDR_DIR} diff --git a/third_party/libassimp/tnt/CMakeLists.txt b/third_party/libassimp/tnt/CMakeLists.txt index 72213b9fbc..9f03a89b49 100644 --- a/third_party/libassimp/tnt/CMakeLists.txt +++ b/third_party/libassimp/tnt/CMakeLists.txt @@ -310,26 +310,30 @@ include_directories(${SRC_DIR}/code/BoostWorkaround) # we're building a library add_library(${TARGET} STATIC ${PRIVATE_HDRS} ${PUBLIC_HDRS} ${SRCS}) -target_compile_options(${TARGET} - PRIVATE -Wno-strict-aliasing - PRIVATE -Wno-sign-compare - PRIVATE -Wno-unused-const-variable - PRIVATE -Wno-unused-private-field - PRIVATE -Wno-unused-variable - PRIVATE -Wno-deprecated-declarations - PRIVATE -Wno-parentheses - PRIVATE -Wno-uninitialized - PRIVATE -Wno-strict-overflow - PRIVATE -Wno-deprecated-register - PRIVATE -Wno-tautological-undefined-compare - PRIVATE -Wno-incompatible-pointer-types - PRIVATE -Wno-tautological-compare - PRIVATE -Wno-undefined-var-template -) +if(NOT MSVC) + target_compile_options(${TARGET} + PRIVATE -Wno-strict-aliasing + PRIVATE -Wno-sign-compare + PRIVATE -Wno-unused-const-variable + PRIVATE -Wno-unused-private-field + PRIVATE -Wno-unused-variable + PRIVATE -Wno-deprecated-declarations + PRIVATE -Wno-parentheses + PRIVATE -Wno-uninitialized + PRIVATE -Wno-strict-overflow + PRIVATE -Wno-deprecated-register + PRIVATE -Wno-tautological-undefined-compare + PRIVATE -Wno-incompatible-pointer-types + PRIVATE -Wno-tautological-compare + PRIVATE -Wno-undefined-var-template + ) +else() + target_compile_options(${TARGET} PRIVATE /bigobj) +endif() if (NOT WIN32) target_compile_options(${TARGET} PRIVATE -Wno-address-of-packed-member) -else() +elseif(NOT MSVC) # Making this option public because the warnings occurs in public headers of libassimp target_compile_options(${TARGET} PUBLIC -Wno-pragma-pack) # RapidJSON disables warnings in-code that clang-cl doesnt know about diff --git a/third_party/libgtest/tnt/CMakeLists.txt b/third_party/libgtest/tnt/CMakeLists.txt index 189a6ade8d..a88f823780 100644 --- a/third_party/libgtest/tnt/CMakeLists.txt +++ b/third_party/libgtest/tnt/CMakeLists.txt @@ -13,6 +13,12 @@ set(SRCS ${SRC_DIR}/gtest-all.cc ) +if (MSVC) + # The /Zc:__cplusplus compiler option enables the __cplusplus preprocessor macro to + # report an updated value for recent C++ language standards support. By default, + # Visual Studio always returns the value "199711L" for the __cplusplus preprocessor macro. + add_definitions(/Zc:__cplusplus) +endif() include_directories( ${PUBLIC_HDR_DIR} diff --git a/third_party/libsdl2/tnt/CMakeLists.txt b/third_party/libsdl2/tnt/CMakeLists.txt index 6565de0cb6..17f958cddb 100755 --- a/third_party/libsdl2/tnt/CMakeLists.txt +++ b/third_party/libsdl2/tnt/CMakeLists.txt @@ -147,27 +147,31 @@ add_library(${TARGET} SHARED ${SRCS}) # libraries we're linking against target_link_libraries(${TARGET} ${EXTRA_LIBS}) -target_compile_options(${TARGET} - PRIVATE -msse2 - PRIVATE -msse - PRIVATE -mmmx - PRIVATE -Wno-unused-variable - PRIVATE -Wno-deprecated-declarations - PRIVATE -Wno-switch - PRIVATE -Wno-tautological-pointer-compare - PRIVATE -Wno-parentheses-equality -) +if(NOT MSVC) + target_compile_options(${TARGET} + PRIVATE -msse2 + PRIVATE -msse + PRIVATE -mmmx + PRIVATE -Wno-unused-variable + PRIVATE -Wno-deprecated-declarations + PRIVATE -Wno-switch + PRIVATE -Wno-tautological-pointer-compare + PRIVATE -Wno-parentheses-equality + ) +endif() # specify where the public headers of this library are target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) if (WIN32) - # Making this option public because the warning occurs in public headers - target_compile_options(${TARGET} PUBLIC -Wno-pragma-pack) - target_compile_options(${TARGET} PRIVATE -Wno-unused-local-typedef) # Windows needs a WinMain static library. add_library(${TARGET}main ${SRC_DIR}/main/windows/SDL_windows_main.c) - target_compile_options(${TARGET}main PRIVATE -Wno-pragma-pack) + if(NOT MSVC) + # Making this option public because the warning occurs in public headers + target_compile_options(${TARGET} PUBLIC -Wno-pragma-pack) + target_compile_options(${TARGET} PRIVATE -Wno-unused-local-typedef) + target_compile_options(${TARGET}main PRIVATE -Wno-pragma-pack) + endif() else() target_compile_options(${TARGET} PRIVATE -fvisibility=hidden) endif() diff --git a/third_party/libz/tnt/CMakeLists.txt b/third_party/libz/tnt/CMakeLists.txt index cc706ee1bd..0b865908cb 100644 --- a/third_party/libz/tnt/CMakeLists.txt +++ b/third_party/libz/tnt/CMakeLists.txt @@ -45,10 +45,12 @@ set(SRCS ${SRC_DIR}/zutil.c ) -add_definitions( - -Wno-implicit-function-declaration - -Wno-shift-negative-value -) +if (NOT MSVC) + add_definitions( + -Wno-implicit-function-declaration + -Wno-shift-negative-value + ) +endif() # we're building a library add_library(${TARGET} STATIC ${PRIVATE_HDRS} ${PUBLIC_HDRS} ${SRCS}) diff --git a/third_party/smol-v/tnt/CMakeLists.txt b/third_party/smol-v/tnt/CMakeLists.txt index 10d94d36f4..a9049198a2 100644 --- a/third_party/smol-v/tnt/CMakeLists.txt +++ b/third_party/smol-v/tnt/CMakeLists.txt @@ -13,10 +13,13 @@ set(SRCS add_library(${TARGET} STATIC ${SRCS}) target_compile_options(${TARGET} PRIVATE - -Wno-tautological-unsigned-enum-zero-compare $<$:-fPIC> ) +if (NOT MSVC) + target_compile_options(${TARGET} PRIVATE -Wno-tautological-unsigned-enum-zero-compare) +endif() + target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) install(TARGETS ${TARGET} ARCHIVE DESTINATION lib/${DIST_DIR}) diff --git a/third_party/tinyexr/tnt/CMakeLists.txt b/third_party/tinyexr/tnt/CMakeLists.txt index a34b2569f3..f8f1ed574f 100644 --- a/third_party/tinyexr/tnt/CMakeLists.txt +++ b/third_party/tinyexr/tnt/CMakeLists.txt @@ -21,6 +21,6 @@ add_library(${TARGET} STATIC ${PUBLIC_HDRS} ${SRCS}) target_include_directories (${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) target_link_libraries(${TARGET} LINK_PUBLIC z) -if (CLANG_CL) +if (CLANG_CL AND NOT MSVC) target_compile_options(${TARGET} PRIVATE -Wno-unused-variable) endif() diff --git a/tools/cmgen/CMakeLists.txt b/tools/cmgen/CMakeLists.txt index 5cdb6c778d..6e2f90f522 100644 --- a/tools/cmgen/CMakeLists.txt +++ b/tools/cmgen/CMakeLists.txt @@ -33,6 +33,10 @@ else() target_compile_options(${TARGET} PRIVATE -ffast-math) endif() +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /Zc:__cplusplus") +endif() + # ================================================================================================= # Licenses # ================================================================================================== diff --git a/tools/filamesh/CMakeLists.txt b/tools/filamesh/CMakeLists.txt index 055d30ab99..e53c9c2dd3 100644 --- a/tools/filamesh/CMakeLists.txt +++ b/tools/filamesh/CMakeLists.txt @@ -24,14 +24,14 @@ target_link_libraries(${TARGET} PRIVATE getopt filameshio meshoptimizer) # ================================================================================================== # Compile options and optimizations # ================================================================================================== -target_compile_options(${TARGET} PRIVATE - -Wno-deprecated-register -) +if(NOT MSVC) + target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) -if (NOT LINUX) - target_compile_options(${TARGET} PRIVATE - -Wno-address-of-packed-member - ) + if (NOT LINUX) + target_compile_options(${TARGET} PRIVATE + -Wno-address-of-packed-member + ) + endif() endif() # =================================================================================================