Skip to content

Commit

Permalink
Try to fix catch2 static link bug on win.
Browse files Browse the repository at this point in the history
Although I'm off a windows pc...
  • Loading branch information
crupest committed Oct 16, 2023
1 parent b96302d commit 0a67b1c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
cmake_minimum_required(VERSION 3.21)

# This make option variable not override normal variable.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# Note the next line won't work because cmake policy is scoped and won't affect subdir.
# cmake_policy(SET CMP0077 NEW)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CRU_DEFAULT_BUILD_SHARED_LIBS ON)
# We default to build shared libs.
set(BUILD_SHARED_LIBS ON)
if (EMSCRIPTEN)
# WebAssembly has no idea about static/dynamic libraries.
set(CRU_DEFAULT_BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF)
endif()

option(BUILD_SHARED_LIBS "Try to build shared libraries as default" ${CRU_DEFAULT_BUILD_SHARED_LIBS})

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand All @@ -19,7 +23,12 @@ if (APPLE)
include_directories(BEFORE SYSTEM "/usr/local/include")
endif()

# Catch2 requires static link.
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(lib/Catch2)
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})

add_subdirectory(lib/double-conversion)
add_subdirectory(lib/GSL)

Expand Down

0 comments on commit 0a67b1c

Please sign in to comment.