Skip to content

Commit

Permalink
test musl cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Liao committed Aug 28, 2024
1 parent a367ea1 commit 1373904
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ if(BUILD_SYMUSIC_PY)
NB_DOMAIN symusic
py_src/core.cpp py_src/py_utils.h py_src/bind_vector_copy.h
)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_library(MUSL_LIB musl)
# Static Link to MUSL for Linux if MUSL is detected
if (MUSL_LIB)
message(STATUS "MUSL detected, static link to musl")

set_target_properties(core PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(core PROPERTIES LINK_SEARCH_END_STATIC 1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
target_link_libraries(core PRIVATE ${MUSL_LIB})

set_target_properties(abc2midi PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(abc2midi PROPERTIES LINK_SEARCH_END_STATIC 1)
target_link_libraries(abc2midi PRIVATE ${MUSL_LIB})

set_target_properties(midi2abc PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(midi2abc PROPERTIES LINK_SEARCH_END_STATIC 1)
target_link_libraries(midi2abc PRIVATE ${MUSL_LIB})
endif()
endif()
target_link_libraries(core PRIVATE symusic)

install(TARGETS core LIBRARY DESTINATION symusic)
Expand Down

0 comments on commit 1373904

Please sign in to comment.