forked from Andersbakken/rtags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnsureLibraries.cmake
46 lines (35 loc) · 1.87 KB
/
EnsureLibraries.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#### EnsureLibraries
# Macro for copying needed libraries to target directory
MACRO(EnsureLibraries EXE_NAME LIBRARY_NAMES )
FOREACH ( LIBRARY_NAME IN ITEMS ${LIBRARY_NAMES} )
GET_TARGET_PROPERTY ( libLocation "${LIBRARY_NAME}" LOCATION )
IF ( NOT "${libLocation}" STREQUAL "libLocation-NOTFOUND" )
GET_TARGET_PROPERTY ( exeLocation "${EXE_NAME}" LOCATION )
IF ( CMAKE_COMPILER_IS_GNUCC )
ADD_CUSTOM_COMMAND ( TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -D LIBRARY="${libLocation}" -D TARGET="${exeLocation}" -P "${CMAKE_SOURCE_DIR}/cmake/EnsureLibrariesRunner.cmake"
COMMENT "Copy lib ${LIBRARY_NAME} to ${EXE_NAME} build ..."
DEPENDS ${LIBRARY_NAME}
)
ELSE ( CMAKE_COMPILER_IS_GNUCC )
INCLUDE(GenerateExportHeader)
IF ( NOT CYGWIN )
GENERATE_EXPORT_HEADER( ${LIBRARY_NAME}
BASE_NAME ${LIBRARY_NAME}
EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
EXPORT_FILE_NAME ${LIBRARY_NAME}_Export.h
STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
)
ENDIF ( NOT CYGWIN )
ADD_CUSTOM_COMMAND ( TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${libLocation}" "$<TARGET_FILE_DIR:${EXE_NAME}>"
COMMENT "Copy lib ${LIBRARY_NAME} to ${EXE_NAME} build ..."
DEPENDS ${LIBRARY_NAME}
DEPENDS osswin
)
ENDIF ( CMAKE_COMPILER_IS_GNUCC )
ENDIF ( NOT "${libLocation}" STREQUAL "libLocation-NOTFOUND" )
ENDFOREACH ( LIBRARY_NAME IN ITEMS ${LIBRARY_NAMES} )
ENDMACRO(EnsureLibraries)