diff --git a/cmake/options.cmake b/cmake/options.cmake index 11b89b408..3b5506518 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -41,6 +41,12 @@ option(WITH_QCHART "When building GUI(need BUILD_GUI=ON), use Qt5 Chart option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF) option(USE_Z3 "Usage of z3 library" OFF) +if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16") + set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers") +else() + set(CMAKE_DISABLE_PRECOMPILE_HEADERS On CACHE BOOL "Disable precompiled headers") +endif() + set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "Output directory for headers") set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/lib CACHE PATH "Output directory for libraries") diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 9eda36b14..6945539d4 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -5,6 +5,7 @@ message( STATUS "Compiler = ${CMAKE_CXX_COMPILER_ID}") message( STATUS "Compiler Version = ${CMAKE_CXX_COMPILER_VERSION}") message( STATUS "Build type = ${CMAKE_BUILD_TYPE}") message( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" ) +message( STATUS "CMAKE_DISABLE_PRECOMPILE_HEADERS = ${CMAKE_DISABLE_PRECOMPILE_HEADERS}" ) message( STATUS "C++ flags (General) = ${CMAKE_CXX_FLAGS}") message( STATUS "C++ flags (Release) = ${CMAKE_CXX_FLAGS_RELEASE}") message( STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8061061f1..6a8167c76 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -37,13 +37,13 @@ else() endif() add_library(lib_objs OBJECT ${srcs_lib} ${hdrs}) -if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16") +if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) target_precompile_headers(lib_objs PRIVATE precompiled.h) endif() if (ENABLE_OSS_FUZZ AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_library(lib_objs_sanitized OBJECT EXCLUDE_FROM_ALL ${srcs_lib} ${hdrs}) target_compile_options(lib_objs_sanitized PRIVATE -fsanitize=address) - if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16") + if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) target_precompile_headers(lib_objs_sanitized PRIVATE precompiled.h) endif() endif()