Support macos
This commit is contained in:
@@ -38,12 +38,24 @@ function(bundle_static_library tgt_name bundled_tgt_name)
|
|||||||
set(bundled_tgt_full_name
|
set(bundled_tgt_full_name
|
||||||
${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${bundled_tgt_name}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${bundled_tgt_name}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
|
|
||||||
if (UNIX OR APPLE)
|
if (APPLE)
|
||||||
file(WRITE ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in
|
find_program(lib_tool libtool)
|
||||||
"CREATE ${bundled_tgt_full_name}\n" )
|
|
||||||
|
|
||||||
foreach(tgt IN LISTS static_libs)
|
foreach(tgt IN LISTS static_libs)
|
||||||
file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in
|
list(APPEND static_libs_full_names $<TARGET_FILE:${tgt}>)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
COMMAND ${lib_tool} -static -o ${bundled_tgt_full_name} ${static_libs_full_names}
|
||||||
|
OUTPUT ${bundled_tgt_full_name}
|
||||||
|
COMMENT "Bundling ${bundled_tgt_name}"
|
||||||
|
VERBATIM)
|
||||||
|
elseif(UNIX)
|
||||||
|
file(WRITE ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in
|
||||||
|
"CREATE ${bundled_tgt_full_name}\n" )
|
||||||
|
|
||||||
|
foreach(tgt IN LISTS static_libs)
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in
|
||||||
"ADDLIB $<TARGET_FILE:${tgt}>\n")
|
"ADDLIB $<TARGET_FILE:${tgt}>\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -51,20 +63,20 @@ function(bundle_static_library tgt_name bundled_tgt_name)
|
|||||||
file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in "END\n")
|
file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in "END\n")
|
||||||
|
|
||||||
file(GENERATE
|
file(GENERATE
|
||||||
OUTPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar
|
OUTPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar
|
||||||
INPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in)
|
INPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar.in)
|
||||||
|
|
||||||
set(ar_tool ${CMAKE_AR})
|
set(ar_tool ${CMAKE_AR})
|
||||||
if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||||
set(ar_tool ${CMAKE_CXX_COMPILER_AR})
|
set(ar_tool ${CMAKE_CXX_COMPILER_AR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMAND ${ar_tool} -M < ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar
|
COMMAND ${ar_tool} -M < ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.ar
|
||||||
OUTPUT ${bundled_tgt_full_name}
|
OUTPUT ${bundled_tgt_full_name}
|
||||||
COMMENT "Bundling ${bundled_tgt_name}"
|
COMMENT "Bundling ${bundled_tgt_name}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
elseif(MSVC)
|
elseif(WIN32)
|
||||||
find_program(lib_tool lib)
|
find_program(lib_tool lib)
|
||||||
|
|
||||||
foreach(tgt IN LISTS static_libs)
|
foreach(tgt IN LISTS static_libs)
|
||||||
|
|||||||
Reference in New Issue
Block a user