Skip to content

Commit

Permalink
tried to import external dependencies and export them afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
SrTobi committed Dec 22, 2014
1 parent e57d67b commit 3f1e730
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions cmake/Macros.cmake
Expand Up @@ -122,6 +122,29 @@ macro(sfml_add_library target)
target_include_directories(${target} PUBLIC $<INSTALL_INTERFACE:include>)
endmacro()

macro(sfml_import_external_library target)

# parse the arguments
cmake_parse_arguments(THIS "SHARED;STATIC" "" "LINK_FILES" ${ARGN})

if(THIS_SHARED)
add_library(${target} SHARED IMPORTED)
elseif(THIS_STATIC)
add_library(${target} STATIC IMPORTED)
else()
add_library(${target} UNKNOWN IMPORTED)
endif()

# add library files
set_target_properties(${target} PROPERTIES IMPORTED_IMPLIB_DEBUG "${THIS_LINK_FILES}")

install(TARGETS ${target} EXPORT sfml-package-target
RUNTIME DESTINATION bin COMPONENT bin
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
endmacro(sfml_import_external_library)

# add a new target which is a SFML example
# ex: sfml_add_example(ftp
# SOURCES ftp.cpp ...
Expand Down
4 changes: 3 additions & 1 deletion src/SFML/Audio/CMakeLists.txt
Expand Up @@ -56,7 +56,9 @@ include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR})
if(SFML_OS_ANDROID)
list(APPEND AUDIO_EXT_LIBS -landroid -lOpenSLES)
endif()
list(APPEND AUDIO_EXT_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})

sfml_import_external_library(external::sndfile-target SHARED LINK_FILES ${SNDFILE_LIBRARY})
list(APPEND AUDIO_EXT_LIBS ${OPENAL_LIBRARY} external::sndfile-target)

# define the sfml-audio target
sfml_add_library(sfml-audio
Expand Down

0 comments on commit 3f1e730

Please sign in to comment.