diff --git a/CMakeLists.txt b/CMakeLists.txt index 25bc973f5..1b80e7c95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ if (FASTGLTF_DOWNLOAD_SIMDJSON) target_compile_features(fastgltf_simdjson PUBLIC cxx_std_17) target_include_directories(fastgltf_simdjson PUBLIC $ $) compiler_flags(TARGET fastgltf_simdjson) + enable_debug_inlining(TARGET fastgltf_simdjson) install( FILES simdjson/simdjson.h diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index c60b0c3fc..a4c675ce5 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -9,8 +9,22 @@ macro(compiler_flags) # cpuid, meaning no architecture flags or other compile flags need to be passed. # See https://github.com/simdjson/simdjson/blob/master/doc/implementation-selection.md. if (MSVC) - target_compile_options(${PARAM_TARGET} PRIVATE /EHsc $<$:/O2 /Ob2 /Ot>) + target_compile_options(${PARAM_TARGET} PRIVATE /EHsc $<$:/O2 /Ob3 /Ot>) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(${PARAM_TARGET} PRIVATE $<$:-O3>) endif() endmacro() + +macro(enable_debug_inlining) + cmake_parse_arguments(PARAM "" "TARGET" "" ${ARGN}) + + if (PARAM_TARGET STREQUAL "" OR NOT TARGET ${PARAM_TARGET}) + return() + endif() + + if (MSVC) + target_compile_options(${PARAM_TARGET} PRIVATE $<$:/Ob2>) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${PARAM_TARGET} PRIVATE $<$:-finline-functions>) + endif() +endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7f031532..da2c10027 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(fastgltf::fastgltf ALIAS fastgltf) target_include_directories(fastgltf PUBLIC $ $) target_compile_features(fastgltf PUBLIC cxx_std_17) compiler_flags(TARGET fastgltf) +enable_debug_inlining(TARGET fastgltf_simdjson) set_target_properties(fastgltf PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES)