diff --git a/.cmake/isce2_buildflags.cmake b/.cmake/isce2_buildflags.cmake index 5570353..255a56a 100644 --- a/.cmake/isce2_buildflags.cmake +++ b/.cmake/isce2_buildflags.cmake @@ -31,3 +31,19 @@ list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${abs_libdir} isSystemDir) if("${isSystemDir}" STREQUAL "-1") list(APPEND CMAKE_INSTALL_RPATH ${abs_libdir}) endif() + +option(ISCE2_STRICT_COMPILATION "Enable strict checks during compilation" ON) +if(ISCE2_STRICT_COMPILATION) + + # Set -fno-common when supported to catch ODR violations + include(CheckCCompilerFlag) + check_c_compiler_flag(-fno-common C_FNO_COMMON) + if(C_FNO_COMMON) + add_compile_options($<$:-fno-common>) + endif() + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-fno-common CXX_FNO_COMMON) + if(CXX_FNO_COMMON) + add_compile_options($<$:-fno-common>) + endif() +endif()