Created
June 1, 2016 23:11
-
-
Save andlabs/bf7d6ebb04b2a5b7a8296154c388992a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro(_add_static _name) | |
add_library(${_name}_uncombined STATIC EXCLUDE_FROM_ALL "${ARGN}") | |
# or alternatively | |
# add_custom_target(${_name}_uncombined SOURCES "${ARGN}") | |
get_target_property(_objs ${_name}_uncombined SOURCES) | |
string(REPLACE ";" " " _objs "${_objs}") | |
add_custom_command( | |
OUTPUT ${_name}_combined.o | |
COMMAND | |
ld -r ${_objs} -o ${_name}_combined.o | |
COMMAND | |
objcopy --localize-hidden ${_name}_combined.o | |
) | |
add_library(${_name} STATIC ${_name}_combined.o) | |
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro(_add_static _name) | |
add_library(${_name} STATIC "${ARGN}") | |
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/sharedhidden) | |
add_custom_command( | |
TARGET ${_name} POST_BUILD | |
COMMAND | |
${CMAKE_AR} x $<TARGET_FILE:${_name}> | |
COMMAND | |
ld -r *.o -o ../_combined_${_name}.o | |
COMMAND | |
objcopy --localize-hidden ../_combined_${_name}.o | |
COMMAND | |
rm $<TARGET_FILE:${_name}> | |
COMMAND | |
${CMAKE_AR} rcs $<TARGET_FILE:${_name}> ../_combined_${_name}.o | |
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/sharedhidden | |
COMMENT "Removing hidden symbols") | |
endmacro() | |
_add_static(libui | |
$<TARGET_OBJECTS:libui-common> | |
$<TARGET_OBJECTS:libui-${_OSDIR}> | |
) | |
common folder: | |
add_library(libui-common OBJECT files...) | |
unix folder: | |
add_library(libui-unix OBJECT files...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment