diff options
author | dan sinclair <dsinclair@google.com> | 2019-05-23 16:27:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-23 16:27:11 -0400 |
commit | d2c0872639b72b7cebbb021e1d860bfe95baeb65 (patch) | |
tree | be4cd30111974edba419ad410a4fd1a4f1e7a4ae | |
parent | 9d11af8005f5ae9568391e70ff6a2bb50861b0fe (diff) | |
download | amber-d2c0872639b72b7cebbb021e1d860bfe95baeb65.tar.gz |
Simplify build settings (#521)
This CL targets the build warnings settings to just the amber source files. This allows us to remove all the overrides needed for building third_party software.
-rw-r--r-- | CMakeLists.txt | 118 | ||||
-rw-r--r-- | third_party/CMakeLists.txt | 342 |
2 files changed, 51 insertions, 409 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e066727..77cef2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,81 +116,63 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR set(COMPILER_IS_LIKE_GNU TRUE) endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CUSTOM_CXX_FLAGS - ${CUSTOM_CXX_FLAGS} - -std=c++11 - -fvisibility=hidden - -Wall - -Werror - -Weverything - -Wextra - -Wno-c++98-compat - -Wno-c++98-compat-pedantic - -Wno-format-pedantic - -Wno-padded - -Wno-switch-enum - -Wno-unknown-pragmas - -Wno-unknown-warning-option) - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CUSTOM_CXX_FLAGS - ${CUSTOM_CXX_FLAGS} - -std=c++11 - -fvisibility=hidden - -Wall - -Werror - -Wextra - -Wno-unknown-pragmas - -Wpedantic - -pedantic-errors) -elseif(MSVC) - # We don't want to have to copy the C Runtime DLL everywhere the executable - # goes. So compile code to assume the CRT is statically linked, i.e. use - # /MT* options. For debug builds use /MTd, and for release builds use /MT. - if(CMAKE_BUILD_TYPE MATCHES "Debug") - set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} /MTd) - message(STATUS "Setting /MTd") - elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} /MT) - message(STATUS "Setting /MT") - else() - set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} /MT) - message(STATUS "Setting /MT") - endif() - - set(CUSTOM_CXX_FLAGS - ${CUSTOM_CXX_FLAGS} - /bigobj - /EHsc - /W3 - /WX - /wd4068 - /wd4514 - /wd4571 - /wd4625 - /wd4626 - /wd4710 - /wd4774 - /wd4820 - /wd5026 - /wd5027 - ) -endif() - -SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${CUSTOM_CXX_FLAGS}") -STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - function(amber_default_compile_options TARGET) if (${COMPILER_IS_LIKE_GNU}) target_compile_options(${TARGET} PRIVATE - -fno-exceptions - -fno-rtti) + -std=c++11 + -fno-exceptions + -fno-rtti + -fvisibility=hidden + -Wall + -Werror + -Wextra + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-format-pedantic + -Wno-padded + -Wno-switch-enum + -Wno-unknown-pragmas + -Wno-unknown-warning-option + -pedantic-errors + ) + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + target_compile_options(${TARGET} PRIVATE -Weverything) + endif() endif() if (MSVC) # Specify /EHs for exception handling. - target_compile_options(${TARGET} PRIVATE /EHs) + target_compile_options(${TARGET} PRIVATE + /bigobj + /EHsc + /W3 + /WX + /wd4068 + /wd4514 + /wd4571 + /wd4625 + /wd4626 + /wd4710 + /wd4774 + /wd4820 + /wd5026 + /wd5027 + ) + + # We don't want to have to copy the C Runtime DLL everywhere the executable + # goes. So compile code to assume the CRT is statically linked, i.e. use + # /MT* options. For debug builds use /MTd, and for release builds use /MT. + if(CMAKE_BUILD_TYPE MATCHES "Debug") + target_compile_options(${TARGET} PRIVATE /MTd) + message(STATUS "Setting /MTd") + elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") + target_compile_options(${TARGET} PRIVATE /MT) + message(STATUS "Setting /MT") + else() + target_compile_options(${TARGET} PRIVATE /MT) + message(STATUS "Setting /MT") + endif() endif() # For MinGW cross compile, statically link to the C++ runtime. diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 256b172..42e0d15 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -12,337 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # Turn off warnings to make gtest happy - set(GTEST_BUILD_FIXES - -Wno-covered-switch-default - -Wno-deprecated - -Wno-disabled-macro-expansion - -Wno-exit-time-constructors - -Wno-exit-time-destructors - -Wno-extra-semi-stmt - -Wno-global-constructors - -Wno-missing-field-initializers - -Wno-format-nonliteral - -Wno-missing-noreturn - -Wno-missing-prototypes - -Wno-missing-variable-declarations - -Wno-shift-sign-overflow - -Wno-sign-conversion - -Wno-undef - -Wno-unused-member-function - -Wno-used-but-marked-unused - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant) - - set(GLSLANG_BUILD_FIXES - -Wno-conversion - -Wno-covered-switch-default - -Wno-date-time - -Wno-deprecated - -Wno-disabled-macro-expansion - -Wno-double-promotion - -Wno-error - -Wno-exit-time-destructors - -Wno-extra-semi - -Wno-extra-semi-stmt - -Wno-float-equal - -Wno-format-nonliteral - -Wno-format-pedantic - -Wno-global-constructors - -Wno-gnu-redeclared-enum - -Wno-implicit-fallthrough - -Wno-inconsistent-missing-destructor-override - -Wno-missing-field-initializers - -Wno-missing-noreturn - -Wno-missing-prototypes - -Wno-missing-variable-declarations - -Wno-newline-eof - -Wno-old-style-cast - -Wno-reserved-id-macro - -Wno-shadow - -Wno-shadow-field - -Wno-shadow-field-in-constructor - -Wno-shift-sign-overflow - -Wno-sign-conversion - -Wno-signed-enum-bitfield - -Wno-undef - -Wno-undefined-func-template - -Wno-undefined-reinterpret-cast - -Wno-unreachable-code - -Wno-unreachable-code-break - -Wno-unreachable-code-return - -Wno-unused-macros - -Wno-unused-parameter - -Wno-unused-variable - -Wno-used-but-marked-unused - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant) - - set(LODEPNG_BUILD_FIXES - -Wno-cast-qual - -Wno-conversion - -Wno-covered-switch-default - -Wno-deprecated - -Wno-extra-semi-stmt - -Wno-implicit-int-conversion - -Wno-missing-prototypes - -Wno-old-style-cast - -Wno-shorten-64-to-32 - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant) - - set(SPIRV_TOOLS_BUILD_FIXES - -Wno-conditional-uninitialized - -Wno-covered-switch-default - -Wno-deprecated - -Wno-documentation - -Wno-documentation-pedantic - -Wno-double-promotion - -Wno-extra-semi - -Wno-extra-semi-stmt - -Wno-float-equal - -Wno-format-nonliteral - -Wno-implicit-fallthrough - -Wno-missing-prototypes - -Wno-old-style-cast - -Wno-range-loop-analysis - -Wno-shift-sign-overflow - -Wno-unreachable-code-break - -Wno-unreachable-code-return - -Wno-unused-member-function - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant) - - set(SHADERC_BUILD_FIXES - -Wno-comma - -Wno-conversion - -Wno-covered-switch - -Wno-covered-switch-default - -Wno-deprecated - -Wno-disabled-macro-expansion - -Wno-double-promotion - -Wno-extra-semi - -Wno-float-equal - -Wno-global-constructors - -Wno-inconsistent-missing-destructor-override - -Wno-missing-field-initializers - -Wno-missing-prototypes - -Wno-newline-eof - -Wno-old-style-cast - -Wno-reserved-id-macro - -Wno-shadow - -Wno-shadow-field - -Wno-shadow-field-in-constructor - -Wno-shadow-uncaptured-local - -Wno-sign-conversion - -Wno-signed-enum-bitfield - -Wno-undef - -Wno-unreachable-code-return - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant - ) - - set(VULKAN_LOADER_BUILD_FIXES - -Wno-unknown-warning-option - ) - - set(SWIFTSHADER_BUILD_FIXES - -Wno-cast-align - -Wno-cast-qual - -Wno-comma - -Wno-conditional-uninitialized - -Wno-conversion - -Wno-covered-switch-default - -Wno-deprecated - -Wno-disabled-macro-expansion - -Wno-documentation-unknown-command - -Wno-double-promotion - -Wno-error - -Wno-exit-time-destructors - -Wno-extra-semi - -Wno-float-equal - -Wno-format-nonliteral - -Wno-global-constructors - -Wno-gnu-anonymous-struct - -Wno-gnu-zero-variadic-macro-arguments - -Wno-header-hygiene - -Wno-implicit-fallthrough - -Wno-inconsistent-missing-destructor-override - -Wno-keyword-macro - -Wno-missing-field-initializers - -Wno-missing-noreturn - -Wno-missing-prototypes - -Wno-missing-variable-declarations - -Wno-nested-anon-types - -Wno-newline-eof - -Wno-non-virtual-dtor - -Wno-old-style-cast - -Wno-range-loop-analysis - -Wno-redundant-parens - -Wno-reserved-id-macro - -Wno-return-std-move-in-c++11 - -Wno-shift-sign-overflow - -Wno-sign-conversion - -Wno-signed-enum-bitfield - -Wno-shadow - -Wno-shadow-field - -Wno-shadow-field-in-constructor - -Wno-shorten-64-to-32 - -Wno-tautological-unsigned-zero-compare - -Wno-undef - -Wno-undefined-func-template - -Wno-undefined-reinterpret-cast - -Wno-used-but-marked-unused - -Wno-unused-parameter - -Wno-unused-macros - -Wno-unused-member-function - -Wno-unused-template - -Wno-unreachable-code - -Wno-unreachable-code-break - -Wno-unreachable-code-return - -Wno-weak-template-vtables - -Wno-weak-vtables - -Wno-zero-as-null-pointer-constant - ) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(GTEST_BUILD_FIXES "") - - set(GLSLANG_BUILD_FIXES - -Wno-error - -Wno-implicit-fallthrough - -Wno-overflow - -Wno-missing-field-initializers - -Wno-pedantic - -Wno-strict-aliasing - -Wno-unused-parameter - -Wno-unused-variable) - - set(LODEPNG_BUILD_FIXES "") - - set(SPIRV_TOOLS_BUILD_FIXES "") - - set(SHADERC_BUILD_FIXES - -Wno-missing-field-initializers - -Wno-pedantic) - - set(VULKAN_LOADER_BUILD_FIXES "") - - set(SWIFTSHADER_BUILD_FIXES - -Wno-all - -Wno-error - -Wno-pedantic - ) -endif() - -if (MSVC) - set(GTEST_BUILD_FIXES - /W3 - /wd4061 - /wd4365 - /wd4514 - /wd4571 - /wd4623 - /wd4625 - /wd4626 - /wd4668 - /wd4710 - /wd4774 - /wd4820 - /wd5026 - /wd5027 - /wd5039 - /wd5045) - - set(GLSLANG_BUILD_FIXES - /W3 - /wd4242 - /wd4244 - /wd4571 - /wd4623 - /wd4625 - /wd4626 - /wd4702 - /wd4774 - /wd4820 - /wd4946 - /wd4996 - /wd5026 - /wd5027 - /wd5045) - - set(LODEPNG_BUILD_FIXES - /W3 - /wd4267) - - set(SPIRV_TOOLS_BUILD_FIXES - /W3 - /wd4365 - /wd4389 - /wd4571 - /wd4623 - /wd4625 - /wd4626 - /wd4702 - /wd4706 - /wd4710 - /wd4774 - /wd4820 - /wd4826 - /wd4868 - /wd5026 - /wd5027 - /wd5045) - - set(SHADERC_BUILD_FIXES - /W3 - /wd4365 - /wd4571 - /wd4623 - /wd4625 - /wd4626 - /wd4702 - /wd4774 - /wd4820 - /wd4996 - /wd5026 - /wd5027 - /wd5039 - /wd5045) - - set(VULKAN_LOADER_BUILD_FIXES - /W3 - ) - - set(SWIFTSHADER_BUILD_FIXES - /W3 - ) -endif() - if (${AMBER_ENABLE_TESTS}) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${GTEST_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) endif() if (${AMBER_ENABLE_SPIRV_TOOLS}) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${SPIRV_TOOLS_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "") set(SPIRV_SKIP_TESTS ON CACHE BOOL ON) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools EXCLUDE_FROM_ALL) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) endif() if (${AMBER_ENABLE_SHADERC}) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${GLSLANG_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(ENABLE_HLSL ON CACHE BOOL ON) set(BUILD_TESTING FALSE CACHE BOOL ON) set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL ON) @@ -352,52 +32,32 @@ if (${AMBER_ENABLE_SHADERC}) set(LLVM_USE_CRT_RELEASE MT CACHE STRING "") set(LLVM_USE_CRT_RELWITHDEBINFO MT CACHE STRING "") add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glslang) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${SHADERC_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(SHADERC_THIRD_PARTY_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "") set(SHADERC_SKIP_TESTS ON CACHE BOOL ON) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/shaderc) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) endif() if (${AMBER_ENABLE_SAMPLES}) # Lodepng set(LODEPNG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lodepng/lodepng.cpp) - STRING(REGEX REPLACE ";" " " LODEPNG_BUILD_FIXES "${LODEPNG_BUILD_FIXES}") - - set_source_files_properties( - ${LODEPNG_SOURCES} - PROPERTIES - COMPILE_FLAGS "${LODEPNG_BUILD_FIXES}") - add_library(lodepng STATIC ${LODEPNG_SOURCES}) endif() if (${AMBER_USE_LOCAL_VULKAN}) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vulkan-headers) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${VULKAN_LOADER_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(BUILD_TESTS FALSE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vulkan-loader) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) endif() if (${AMBER_ENABLE_SWIFTSHADER}) - set(CXX_BACK ${CMAKE_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${SWIFTSHADER_BUILD_FIXES}") - STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(BUILD_EGL FALSE CACHE BOOL FALSE) set(BUILD_GLESv2 FALSE CACHE BOOL FALSE) set(BUILD_GLES_CM FALSE CACHE BOOL FALSE) set(BUILD_VULKAN TRUE CACHE BOOL TRUE) set(BUILD_SAMPLES FALSE CACHE BOOL FALSE) set(BUILD_TESTS FALSE CACHE BOOL FALSE) + set(WARNINGS_AS_ERRORS FALSE CACHE BOOL FALSE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/swiftshader) - set(CMAKE_CXX_FLAGS ${CXX_BACK}) endif() |