Update CMake configuration to support building with MSVC

This commit is contained in:
Gregory Popovitch
2019-09-23 13:15:34 -04:00
committed by Ben Doherty
parent 4eba402adb
commit a34903aa33
23 changed files with 219 additions and 130 deletions

2
.gitignore vendored
View File

@@ -12,3 +12,5 @@ filament/docs/html/**
gltf_baker.ini
*tmp*.png
civetweb.txt
/out*
/TAGS

View File

@@ -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.
# ==================================================================================================

View File

@@ -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

View File

@@ -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

View File

@@ -87,7 +87,9 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
# ==================================================================================================
# Compiler flags
# ==================================================================================================
target_compile_options(${TARGET} PRIVATE
-Wno-deprecated-register
$<$<CONFIG:Release>:-ffast-math>
)
if (NOT MSVC_NATIVE)
target_compile_options(${TARGET} PRIVATE
-Wno-deprecated-register
$<$<CONFIG:Release>:-ffast-math>
)
endif()

View File

@@ -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
# ==================================================================================================

View File

@@ -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 $<$<CONFIG:Release>:/fp:fast>)

View File

@@ -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 $<$<CONFIG:Release>:/fp:fast>)

View File

@@ -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 $<$<CONFIG:Release>:/fp:fast>)

View File

@@ -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 $<$<CONFIG:Release>:/fp:fast>)

View File

@@ -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 $<$<CONFIG:Release>:/fp:fast>)
else()

View File

@@ -235,9 +235,11 @@ list(APPEND APP_LIBS sample-app)
# Compiler flags
# ==================================================================================================
set(COMPILER_FLAGS
-Wno-extern-c-compat
$<$<NOT:$<PLATFORM_ID:Linux>>:-Wno-address-of-packed-member>)
if (NOT MSVC_NATIVE)
set(COMPILER_FLAGS
-Wno-extern-c-compat
$<$<NOT:$<PLATFORM_ID:Linux>>:-Wno-address-of-packed-member>)
endif()
if (MSVC OR CLANG_CL)
set(COMPILER_FLAGS ${COMPILER_FLAGS} $<$<CONFIG:Release>:/fp:fast>)

View File

@@ -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})

View File

@@ -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)

View File

@@ -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}

View File

@@ -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

View File

@@ -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}

View File

@@ -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()

View File

@@ -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})

View File

@@ -13,10 +13,13 @@ set(SRCS
add_library(${TARGET} STATIC ${SRCS})
target_compile_options(${TARGET} PRIVATE
-Wno-tautological-unsigned-enum-zero-compare
$<$<PLATFORM_ID:Linux>:-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})

View File

@@ -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()

View File

@@ -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
# ==================================================================================================

View File

@@ -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()
# =================================================================================================