From 2c0b079dc94e48100826bc4c366dd3c2cd6cd6fe Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 15 Oct 2018 23:49:05 -0600 Subject: [PATCH] CMake: Disable C++ exceptions everywhere that doesn't request them --- CMakeLists.txt | 14 ++++++++++++++ panda/src/pnmimagetypes/CMakeLists.txt | 1 + 2 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2d5d3b6d2..a2116607a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,20 @@ if(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() +# As long as we're figuring out compiler flags, figure out the flags for +# turning C++ exception support on and off +if(MSVC) + set(cxx_exceptions_on "/EHsc") + set(cxx_exceptions_off "/D_HAS_EXCEPTIONS=0") +else() + set(cxx_exceptions_on "-fexceptions") + set(cxx_exceptions_off "-fno-exceptions") +endif() +set(cxx_exceptions_property "$>") +add_compile_options( + "$<${cxx_exceptions_property}:${cxx_exceptions_on}>" + "$<$:${cxx_exceptions_off}>") + # Include global modules needed for configure scripts include(PackageConfig) # Defines package_option diff --git a/panda/src/pnmimagetypes/CMakeLists.txt b/panda/src/pnmimagetypes/CMakeLists.txt index 688caba7c5..8fcac02573 100644 --- a/panda/src/pnmimagetypes/CMakeLists.txt +++ b/panda/src/pnmimagetypes/CMakeLists.txt @@ -34,6 +34,7 @@ composite_sources(p3pnmimagetypes P3PNMIMAGETYPES_SOURCES) add_component_library(p3pnmimagetypes SYMBOL BUILDING_PANDA_PNMIMAGETYPES ${P3PNMIMAGETYPES_HEADERS} ${P3PNMIMAGETYPES_SOURCES}) target_link_libraries(p3pnmimagetypes p3pnmimage PKG::JPEG PKG::TIFF PKG::PNG) +set_target_properties(p3pnmimagetypes PROPERTIES CXX_EXCEPTIONS ON) if(NOT BUILD_METALIBS) install(TARGETS p3pnmimagetypes DESTINATION lib RUNTIME DESTINATION bin)