Skip to content

Commit

Permalink
Use correct libraries when compiling statically (drogonframework#2136)
Browse files Browse the repository at this point in the history
When compiling statically, cmake pulls shared libraries as dependencies
for drogon e.g. libpq.so instead of libpq.a. This causes linkage errors
when compiling the whole program.

The flag USE_STATIC_LIBS_ONLY should set the CMAKE_FIND_LIBRARY_SUFFIXES
to the appropriate suffix on different platforms, thus find_* commands
find the right library.
  • Loading branch information
omar-mohamed-khallaf authored Aug 22, 2024
1 parent 5b5d190 commit 80ec7d9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ option(BUILD_DOC "Build Doxygen documentation" OFF)
option(BUILD_BROTLI "Build Brotli" ON)
option(BUILD_YAML_CONFIG "Build yaml config" ON)
option(USE_SUBMODULE "Use trantor as a submodule" ON)
option(USE_STATIC_LIBS_ONLY "Use only static libraries as dependencies" OFF)

include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_POSTGRESQL "Build with postgresql support" ON "BUILD_ORM" OFF)
Expand Down Expand Up @@ -77,6 +78,10 @@ if (BUILD_SHARED_LIBS)
endif ()
endif (BUILD_SHARED_LIBS)

if(USE_STATIC_LIBS_ONLY)
set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif(USE_STATIC_LIBS_ONLY)

if(USE_SPDLOG)
find_package(spdlog CONFIG)
if(spdlog_FOUND)
Expand Down

0 comments on commit 80ec7d9

Please sign in to comment.