Skip to content

Commit

Permalink
Make sure libwinpthread is static linked
Browse files Browse the repository at this point in the history
Not sure why this fixes the lib not being static linked, nor do I know what the
problem was making it not be static linked.
  • Loading branch information
kcat committed Jan 13, 2024
1 parent 6fd5bab commit a7fa088
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ else()
option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
if(ALSOFT_STATIC_WINPTHREAD)
set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH)
set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
unset(OLD_REQUIRED_LIBRARIES)

if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
message(FATAL_ERROR "Cannot static link libwinpthread")
endif()
set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
endif()
endif()
endif()
Expand Down

0 comments on commit a7fa088

Please sign in to comment.