diff --git a/nc.cmake b/nc.cmake index 4408613..93e929b 100644 --- a/nc.cmake +++ b/nc.cmake @@ -13,6 +13,7 @@ set (THREADS_PREFER_PTHREAD_FLAG ON) find_package (Threads REQUIRED) link_libraries (Threads::Threads) +# cxx.cmake must be imported first include ("${CMAKE_CURRENT_LIST_DIR}/nc_cxx.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_sanitizer.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_platform.cmake") diff --git a/nc_cxx.cmake b/nc_cxx.cmake index 40b5667..7478835 100644 --- a/nc_cxx.cmake +++ b/nc_cxx.cmake @@ -32,16 +32,19 @@ append_compile_flag ("/std:c++latest") ############################################################################### -set(STDLIB "libc++" CACHE STRING "Which stdlib to specify for Clang") +# STDLIB must be set after this block. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(STDLIB "libc++") append_compile_flag ("-stdlib=${STDLIB}") append_link_flag ("-fuse-ld=lld") -endif () - -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(STDLIB "libstdc++") append_link_flag ("-fuse-ld=gold") -endif () +else() + message(FATAL_ERROR "Unknown CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") +endif() + ############################################################################### # find the gcc or clang filesystem library and append to libs if needed diff --git a/nc_optimisation.cmake b/nc_optimisation.cmake index 95a589a..d65ffe7 100644 --- a/nc_optimisation.cmake +++ b/nc_optimisation.cmake @@ -192,7 +192,9 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) add_definitions(-DENABLE_DEBUGGING) if (RUNTIME_DEBUGGING) - add_definitions(-D_GLIBCXX_DEBUG) + if ("${STDLIB}" STREQUAL "libstdc++") + add_definitions(-D_GLIBCXX_DEBUG) + endif() endif() # Don't make any commits that use -O0 by default. Instead, either add an