From ff3018647c5253ccbe9a6d324b9a1d6528fe962d Mon Sep 17 00:00:00 2001 From: Darice L Guittet Date: Thu, 14 Nov 2024 07:57:45 -0800 Subject: [PATCH] Cmake edits (#1243) * clean up CMakeLists.txt * updates for sdktool and test * cxx_standard --- CMakeLists.txt | 11 +++-------- sdktool/CMakeLists.txt | 8 ++++++-- ssc/CMakeLists.txt | 9 +++++++-- test/CMakeLists.txt | 3 ++- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40886ced8..d01b0723a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,17 +25,11 @@ if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "12" CACHE STRING "Minimum OS X deployment version") endif() -if (UNIX AND NOT CMAKE_C_COMPILER) - set(CMAKE_C_COMPILER gcc) - set(CMAKE_CXX_COMPILER g++) -endif() -set(CMAKE_CXX_STANDARD 11) - if ( NOT APPLE) set(CURL_DIR build_resources/libcurl_ssl_x64) endif() -Project(sam_simulation_core VERSION 1.0.0) +Project(sam_simulation_core VERSION 1.0.0 LANGUAGES CXX C) ##################################################################################################################### @@ -82,6 +76,8 @@ function(set_default_compile_options target) set(MAIN_CFLAGS "") endif() set(MAIN_CFLAGS "${MAIN_CFLAGS} -D__64BIT__") + set_property(TARGET ${target} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON) if(MSVC) set(MAIN_CFLAGS "${MAIN_CFLAGS} /bigobj /MP") set(MAIN_CFLAGS "${MAIN_CFLAGS} /D__WINDOWS__ /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DLPWINAPP") @@ -89,7 +85,6 @@ function(set_default_compile_options target) set(${flag_var} "${${flag_var}} /D_DEBUG" CACHE STRING "compile flags" FORCE) endforeach() else(MSVC) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if (APPLE) set(MAIN_CFLAGS "${MAIN_CFLAGS} -fno-common -DWX_PRECOMP -D__MACOSX__") else() diff --git a/sdktool/CMakeLists.txt b/sdktool/CMakeLists.txt index 77553fb9d..306349f0d 100644 --- a/sdktool/CMakeLists.txt +++ b/sdktool/CMakeLists.txt @@ -112,11 +112,15 @@ endif() target_link_libraries(SDKtool ${wxWidgets_LIBRARIES}) if (UNIX AND NOT APPLE) - target_link_libraries(SDKtool -ldl -lfontconfig) + target_link_libraries(SDKtool ${CMAKE_DL_LIBS} -lfontconfig) endif() if (UNIX) - target_link_libraries(SDKtool -lm -lcurl) + find_library(MATH_LIBRARY m) + if(MATH_LIBRARY) + target_link_libraries(SDKtool ${MATH_LIBRARY}) + endif() + target_link_libraries(SDKtool -lcurl) elseif (MSVC) find_library( CURL_LIB NAMES libcurl.lib diff --git a/ssc/CMakeLists.txt b/ssc/CMakeLists.txt index 4bf18b386..ba479a77c 100644 --- a/ssc/CMakeLists.txt +++ b/ssc/CMakeLists.txt @@ -247,11 +247,16 @@ set( DEPENDENCIES splinter ) foreach( name ${DEPENDENCIES} ) - target_link_libraries(ssc ${name}) + target_link_libraries(ssc PUBLIC ${name}) endforeach() if (UNIX) - target_link_libraries(ssc -lpthread -lm -ldl -lstdc++) + find_package(Threads REQUIRED) + target_link_libraries(ssc PUBLIC Threads::Threads ${CMAKE_DL_LIBS}) + find_library(MATH_LIBRARY m) + if(MATH_LIBRARY) + target_link_libraries(ssc PUBLIC ${MATH_LIBRARY}) + endif() endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb8d4cd5b..c194c4038 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -90,7 +90,8 @@ endif() target_link_libraries(Test ssc splinter) if (UNIX) - target_link_libraries(Test -ldl -lpthread) + find_package(Threads REQUIRED) + target_link_libraries(Test Threads::Threads ${CMAKE_DL_LIBS}) endif()