diff --git a/CMake/Package.cmake b/CMake/Package.cmake index 39c43d7..2ff7931 100644 --- a/CMake/Package.cmake +++ b/CMake/Package.cmake @@ -114,6 +114,20 @@ function(bigfoot_create_package_tests ParentFolder BigfootDependencies) set_target_properties(${PROJECT_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) endif() + ##################ASAN SETUP################### + + if(${ASAN}) + if (MSVC) + get_filename_component(MSVC_BIN_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY) + set(ASAN_DLL "${MSVC_BIN_DIR}/clang_rt.asan_dynamic-x86_64.dll") + + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "Copying ASan DLL: ${ASAN_DLL} to $" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ASAN_DLL}" "$" + ) + endif() + endif() + ##################COPY FIXTURE FOLDER################### if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Fixture) diff --git a/ConanProfiles/ccache.cmake b/ConanProfiles/ccache.cmake new file mode 100644 index 0000000..5fce6ee --- /dev/null +++ b/ConanProfiles/ccache.cmake @@ -0,0 +1,30 @@ +include_guard() + +# Find ccache executable +find_program(CCACHE_PROGRAM NAMES ccache) + +if(CCACHE_PROGRAM) + message(STATUS "ccache found: ${CCACHE_PROGRAM}, enabling via CMake launcher and environment.") + if (CMAKE_GENERATOR MATCHES "Visual Studio") + # Copy original ccache.exe and rename to cl.exe, this way intermediate cmd file is not needed + file(COPY_FILE ${CCACHE_PROGRAM} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT) + + # Set Visual Studio global variables: + # - Use above cl.exe (ccache.exe) as a compiler + # - Enable parallel compilation + list(APPEND CMAKE_VS_GLOBALS + "CLToolExe=cl.exe" + "CLToolPath=${CMAKE_BINARY_DIR}" + "UseMultiToolTask=true" + "UseStructuredOutput=false" + ) + elseif(CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Unix Makefiles") + message(STATUS "Using ccache as compiler launcher for Ninja or Makefiles.") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) + else() + message(WARNING "Unsupported generator for ccache integration: ${CMAKE_GENERATOR}. ccache will not be used.") + endif() +else() + message(WARNING "ccache not found. Not enabling ccache integration.") +endif() \ No newline at end of file diff --git a/ConanProfiles/clang b/ConanProfiles/clang index dde2d34..1f1e1b1 100644 --- a/ConanProfiles/clang +++ b/ConanProfiles/clang @@ -10,7 +10,7 @@ compiler.runtime=static build_type=Release [conf] -tools.cmake.cmaketoolchain:extra_variables={'CMAKE_CXX_COMPILER_LAUNCHER': 'ccache', 'CMAKE_C_COMPILER_LAUNCHER': 'ccache'} +tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/ccache.cmake tools.system.package_manager:mode=install tools.system.package_manager:sudo=True @@ -18,6 +18,8 @@ tools.system.package_manager:sudo=True tools.build:exelinkflags=["-fuse-ld=mold"] tools.build:sharedlinkflags=["-fuse-ld=mold"] +tools.build:cxxflags=["-fno-exceptions", "-fno-rtti"] + tools.build:compiler_executables={"c": "clang", "cpp": "clang++"} tools.cmake.cmaketoolchain:generator=Ninja diff --git a/ConanProfiles/clang_asan b/ConanProfiles/clang_asan index 22a95e8..4211e5d 100644 --- a/ConanProfiles/clang_asan +++ b/ConanProfiles/clang_asan @@ -10,7 +10,7 @@ compiler.runtime=static build_type=Debug [conf] -tools.cmake.cmaketoolchain:extra_variables={'CMAKE_CXX_COMPILER_LAUNCHER': 'ccache', 'CMAKE_C_COMPILER_LAUNCHER': 'ccache'} +tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/ccache.cmake tools.system.package_manager:mode=install tools.system.package_manager:sudo=True @@ -19,7 +19,7 @@ tools.build:exelinkflags=["-fuse-ld=mold", "-fsanitize=address,undefined,leak"] tools.build:sharedlinkflags=["-fuse-ld=mold", "-fsanitize=address,undefined,leak"] tools.build:cflags=["-fsanitize=address,undefined,leak", "-fno-sanitize-recover=all"] -tools.build:cxxflags=["-fsanitize=address,undefined,leak", "-fno-sanitize-recover=all"] +tools.build:cxxflags=["-fno-exceptions", "-fno-rtti", "-fsanitize=address,undefined,leak", "-fno-sanitize-recover=all"] tools.cmake.cmaketoolchain:generator=Ninja diff --git a/ConanProfiles/clang_coverage b/ConanProfiles/clang_coverage index 8c11889..82fc3ac 100644 --- a/ConanProfiles/clang_coverage +++ b/ConanProfiles/clang_coverage @@ -10,7 +10,7 @@ compiler.runtime=static build_type=Debug [conf] -tools.cmake.cmaketoolchain:extra_variables={'CMAKE_CXX_COMPILER_LAUNCHER': 'ccache', 'CMAKE_C_COMPILER_LAUNCHER': 'ccache'} +tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/ccache.cmake tools.system.package_manager:mode=install tools.system.package_manager:sudo=True @@ -18,6 +18,8 @@ tools.system.package_manager:sudo=True tools.build:exelinkflags=["-fuse-ld=mold"] tools.build:sharedlinkflags=["-fuse-ld=mold"] +tools.build:cxxflags=["-fno-exceptions", "-fno-rtti"] + tools.cmake.cmaketoolchain:generator=Ninja tools.build:compiler_executables={"c": "clang", "cpp": "clang++"} diff --git a/ConanProfiles/msvc b/ConanProfiles/msvc index af1c7c3..cb71236 100644 --- a/ConanProfiles/msvc +++ b/ConanProfiles/msvc @@ -9,10 +9,12 @@ compiler.runtime=static build_type=Release [conf] -tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/msvc_ccache.cmake +tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/ccache.cmake tools.build:cflags=["/Zc:preprocessor", "/Zc:__STDC__", "/D_CRT_DECLARE_NONSTDC_NAMES=1"] -tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/Zc:throwingNew"] +tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/EHs-c-", "/GR-"] + +tools.build:defines=["_HAS_EXCEPTIONS=0"] [tool_requires] !cmake/*: cmake/[>=4.2] diff --git a/ConanProfiles/msvc_asan b/ConanProfiles/msvc_asan index 3a59065..d21af65 100644 --- a/ConanProfiles/msvc_asan +++ b/ConanProfiles/msvc_asan @@ -9,10 +9,12 @@ compiler.runtime=static build_type=Debug [conf] -tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/msvc_ccache.cmake +tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/ccache.cmake -tools.build:cflags=["/Zc:preprocessor", "/Zc:__STDC__", "/D_CRT_DECLARE_NONSTDC_NAMES=1"] -tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/Zc:throwingNew"] +tools.build:cflags=["/Zc:preprocessor", "/Zc:__STDC__", "/D_CRT_DECLARE_NONSTDC_NAMES=1", "/fsanitize=address"] +tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/EHs-c-", "/GR-", "/fsanitize=address"] + +tools.build:defines=["_HAS_EXCEPTIONS=0"] [tool_requires] !cmake/*: cmake/[>=4.2] diff --git a/ConanProfiles/msvc_ccache.cmake b/ConanProfiles/msvc_ccache.cmake deleted file mode 100644 index 2818eec..0000000 --- a/ConanProfiles/msvc_ccache.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# https://github.com/ccache/ccache/wiki/MS-Visual-Studio#usage-with-cmake - -find_program(ccache_exe ccache) -if(ccache_exe) - file(COPY_FILE - ${ccache_exe} ${CMAKE_BINARY_DIR}/cl.exe - ONLY_IF_DIFFERENT) - - # By default Visual Studio generators will use /Zi which is not compatible - # with ccache, so tell Visual Studio to use /Z7 instead. - message(STATUS "Setting MSVC debug information format to 'Embedded'") - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>") - - set(CMAKE_VS_GLOBALS - "CLToolExe=cl.exe" - "CLToolPath=${CMAKE_BINARY_DIR}" - "UseMultiToolTask=true" - ) -endif() \ No newline at end of file