diff --git a/CMakeLists.txt b/CMakeLists.txt index 206490a1..09787a97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,16 @@ elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") add_definitions(-DMUSICA_USING_PGI) endif() +if(MUSICA_BUILD_C_CXX_INTERFACE) + # on ubuntu with clang, an incorrect version of the c++ standard library was being linked + if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # If the compiler is Clang, use libc++ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + endif() + + set(CMAKE_CXX_STANDARD 20) +endif() + ################################################################################ # Dependencies diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 831cc09e..10bb0032 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -9,7 +9,6 @@ endif() ################################################################################ # google test if(MUSICA_ENABLE_TESTS) - set(CMAKE_CXX_STANDARD 20) include(FetchContent) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f4b6e90..7e64cc37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,12 +14,6 @@ include(musica_util) # Add submodules checkout_submodules() -# on ubuntu with clang, an incorrect version of the c++ standard library was being linked -if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # If the compiler is Clang, use libc++ - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -endif() - ############################################################################## # MUSICA targets