Skip to content

Commit

Permalink
Windows: Link statically
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed Dec 5, 2023
1 parent 04bef59 commit 07a3d38
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ option(WITH_CPP_TESTS "Enable building C++ wrapper tests." ON)
option(WITH_STATIC "Enable building static library." OFF)
option(THREADING "Build with threading support." ON)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(WITH_STATIC 1)
endif()

if (WITH_STATIC)
message(STATUS "If you are using the static library build, please keep in mind (and inform yourself of the implications) that liblo is licensed with LGPL v2.1+.")
endif()
Expand Down Expand Up @@ -206,9 +210,6 @@ if (WITH_TESTS)
add_executable(${TESTTCP} ${TESTTCP_SOURCES})
target_link_libraries(${TESTLO} PRIVATE Threads::Threads)
target_link_libraries(${TESTTCP} PRIVATE Threads::Threads)
set_target_properties(${TESTLO} PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mconsole")
set_target_properties(${SUBTEST} PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mconsole")
set_target_properties(${TESTTCP} PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mconsole")
add_test(${TESTLO} tests/${TESTLO})
add_test("test-bidirectional-tcp" tests/${TESTTCP})
enable_testing()
Expand Down Expand Up @@ -286,7 +287,12 @@ foreach(PROG ${PROGRAMS})
target_include_directories(${PROG} PUBLIC
"$<BUILD_INTERFACE:${LO_BUILD_INCLUDE_DIRS}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(${PROG} PUBLIC ${LIBRARY_SHARED})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
# For some yet unknown reasons, Windows has trouble finding the DLL
target_link_libraries(${PROG} PUBLIC ${LIBRARY_STATIC})
else()
target_link_libraries(${PROG} PUBLIC ${LIBRARY_SHARED})
endif()
endforeach(PROG)

foreach(PROG ${TOOLS})
Expand Down

0 comments on commit 07a3d38

Please sign in to comment.