diff --git a/.github/workflows/musl.yml b/.github/workflows/musl.yml index 58eb63f96..b2e51f464 100644 --- a/.github/workflows/musl.yml +++ b/.github/workflows/musl.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: install devel tools run: | - apk add musl-dev git cmake gcc make binutils openssl-dev linux-headers zlib-dev ninja + apk add musl-dev git cmake gcc g++ make binutils openssl-dev linux-headers zlib-dev ninja - name: make run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dca56d73..c6c6a392b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,50 +607,6 @@ if(USE_REM) endif() -############################################################################## -# -# Linking LIBS -# - -set(LINKLIBS Threads::Threads ${RESOLV_LIBRARY}) - -if(BACKTRACE_FOUND) - list(APPEND LINKLIBS ${Backtrace_LIBRARIES}) -endif() - -if(ZLIB_FOUND) - list(APPEND LINKLIBS ZLIB::ZLIB) -endif() - -if(USE_OPENSSL) - list(APPEND LINKLIBS OpenSSL::SSL OpenSSL::Crypto) -endif() - -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - list(APPEND LINKLIBS - "-framework SystemConfiguration" "-framework CoreFoundation" - ) -endif() - -if(WIN32) - list(APPEND LINKLIBS - qwave - iphlpapi - wsock32 - ws2_32 - dbghelp - ) -else() - list(APPEND LINKLIBS m) -endif() - -if(UNIX) - list(APPEND LINKLIBS - ${CMAKE_DL_LIBS} - ) -endif() - - ############################################################################## # # Main target object @@ -675,7 +631,7 @@ target_include_directories(re-objs PRIVATE if(LIBRE_BUILD_SHARED) list(APPEND RE_INSTALL_TARGETS re-shared) add_library(re-shared SHARED $) - target_link_libraries(re-shared PRIVATE ${LINKLIBS}) + target_link_libraries(re-shared PRIVATE ${RE_LIBS}) set_target_properties(re-shared PROPERTIES VERSION ${PROJECT_SOVERSION}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) set_target_properties(re-shared PROPERTIES SOVERSION ${PROJECT_SOVERSION}) @@ -692,7 +648,7 @@ endif() if(LIBRE_BUILD_STATIC) list(APPEND RE_INSTALL_TARGETS re) add_library(re STATIC $) - target_link_libraries(re PUBLIC ${LINKLIBS}) + target_link_libraries(re PUBLIC ${RE_LIBS}) target_include_directories(re PUBLIC $ ) diff --git a/cmake/re-config.cmake b/cmake/re-config.cmake index 6dc0ad8b6..68c0c80cd 100644 --- a/cmake/re-config.cmake +++ b/cmake/re-config.cmake @@ -2,6 +2,7 @@ include(CheckIncludeFile) include(CheckFunctionExists) include(CheckSymbolExists) include(CheckTypeSize) +include(CheckCXXSourceCompiles) option(USE_MBEDTLS "Enable MbedTLS" OFF) @@ -214,3 +215,78 @@ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "[Rr]el") set(CMAKE_ENABLE_EXPORTS ON) endif() endif() + + +############################################################################## +# +# Linking LIBS +# + +set(RE_LIBS Threads::Threads ${RESOLV_LIBRARY}) + +if(BACKTRACE_FOUND) + list(APPEND RE_LIBS ${Backtrace_LIBRARIES}) +endif() + +if(ZLIB_FOUND) + list(APPEND RE_LIBS ZLIB::ZLIB) +endif() + +if(USE_OPENSSL) + list(APPEND RE_LIBS OpenSSL::SSL OpenSSL::Crypto) +endif() + +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + list(APPEND RE_LIBS + "-framework SystemConfiguration" "-framework CoreFoundation" + ) +endif() + +if(WIN32) + list(APPEND RE_LIBS + qwave + iphlpapi + wsock32 + ws2_32 + dbghelp + ) +else() + list(APPEND RE_LIBS m) +endif() + +if(UNIX) + list(APPEND RE_LIBS + ${CMAKE_DL_LIBS} + ) +endif() + + +############################################################################## +# +# Testing Atomic +# + +enable_language(CXX) + +set(ATOMIC_TEST_CODE " + #include + #include + std::atomic n8 (0); // riscv64 + std::atomic n64 (0); // armel, mipsel, powerpc + int main() { + ++n8; + ++n64; + return 0; + }") + +check_cxx_source_compiles("${ATOMIC_TEST_CODE}" atomic_test) + +if(NOT atomic_test) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} atomic) + check_cxx_source_compiles("${ATOMIC_TEST_CODE}" atomic_test_lib) + if(NOT atomic_test_lib) + message(FATAL_ERROR "No builtin or libatomic support") + else() + list(APPEND RE_LIBS atomic) + endif() +endif()