diff --git a/CMakeLists.txt b/CMakeLists.txt index f81a7da0..23d8ea85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/lib/mmse set(ENABLE_PROSTT5 1 CACHE BOOL "Enable ProstT5") set(ENABLE_CUDA 0 CACHE BOOL "Enable CUDA") set(IGNORE_RUST_VERSION 0 CACHE BOOL "Ignore Rust version check") +set(FORCE_STATIC_DEPS 0 CACHE BOOL "Force static linking of deps") -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) +if (FORCE_STATIC_DEPS) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a CACHE INTERNAL "" FORCE) + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) +endif () + +if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif () set(FRAMEWORK_ONLY 1 CACHE INTERNAL "" FORCE) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b2d92142..1a5ad067 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -56,9 +56,8 @@ jobs: mkdir build && cd build export CC=gcc-11 ; export CXX=g++-11 if [ "${STATIC}" -eq "1" ]; then - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc \ - -static-libstdc++" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ + cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DFORCE_STATIC_DEPS=1 \ + -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++" \ -DENABLE_WERROR=1 -DHAVE_${SIMD}=1 -DHAVE_MPI=${MPI} .. else cmake -DHAVE_SANITIZER=1 -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ @@ -111,10 +110,8 @@ jobs: - script: | mkdir build && cd build CC=${CPREF}-linux-gnu-gcc CXX=${CPREF}-linux-gnu-g++ \ - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DHAVE_TESTS=1 \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc \ - -static-libstdc++" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ + cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DHAVE_TESTS=1 -DFORCE_STATIC_DEPS=1 \ + -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++" \ -DRust_CARGO_TARGET=${CPREF}-unknown-linux-gnu \ -DENABLE_WERROR=1 -DHAVE_${SIMD}=1 .. make -j $(nproc --all)