-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbcl_runtime_libraries.cmake
73 lines (68 loc) · 3.04 KB
/
bcl_runtime_libraries.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# runtime for gnu cxx compiler
IF( CMAKE_COMPILER_IS_GNUCXX)
# add libgcc_s_sjlj-1.dll and libstdc++-6.dll to installer
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -print-file-name= OUTPUT_VARIABLE CXX_COMPILER_ROOT)
STRING( REGEX REPLACE "[\n\r\t]+" "" CXX_COMPILER_ROOT ${CXX_COMPILER_ROOT})
SET( CXX_COMPILER_ROOT ${CXX_COMPILER_ROOT}/../../../../)
GET_FILENAME_COMPONENT( CXX_COMPILER_ROOT ${CXX_COMPILER_ROOT} REALPATH)
MESSAGE( STATUS "compiler root: " ${CXX_COMPILER_ROOT})
# runtime library search paths
SET( RUNTIME_LIBRARY_SEARCH_PATHS_SUFFIXES bin)
IF( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
LIST( APPEND RUNTIME_LIBRARY_SEARCH_PATHS_SUFFIXES lib64)
ELSEIF( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
LIST( APPEND RUNTIME_LIBRARY_SEARCH_PATHS_SUFFIXES lib)
ENDIF()
# runtime library file names
IF( MINGW)
# Note: with the current MXE compiler, this is unnecessary since MXE only uses static libs
LIST( APPEND RUNTIME_LIBRARY_SEARCH_PATHS_SUFFIXES bin)
SET( RUNTIME_FILES libstdc++-6.dll libgcc_s_sjlj-1.dll)
ELSEIF( UNIX)
SET( RUNTIME_FILES libstdc++.so.6 libgcc_s.so.1)
ENDIF()
FOREACH( FILE ${RUNTIME_FILES})
FIND_FILE( INSTALL_RUNTIME_FILE ${FILE} PATHS ${CXX_COMPILER_ROOT} PATH_SUFFIXES ${RUNTIME_LIBRARY_SEARCH_PATHS_SUFFIXES} NO_DEFAULT_PATH)
GET_FILENAME_COMPONENT( INSTALL_RUNTIME_FILE ${INSTALL_RUNTIME_FILE} REALPATH)
# remove any new line characters that are present
STRING( REGEX REPLACE "\n" "" INSTALL_RUNTIME_FILE "${INSTALL_RUNTIME_FILE}")
LIST( APPEND INSTALL_RUNTIME_FILES ${INSTALL_RUNTIME_FILE})
UNSET( INSTALL_RUNTIME_FILE CACHE)
UNSET( INSTALL_RUNTIME_FILE)
ENDFOREACH()
# create links to the external libraries for wine
IF( MINGW)
FIND_PROGRAM( WINEPATH winepath PATHS ENV PATH)
IF( WINEPATH)
EXECUTE_PROCESS( COMMAND ${WINEPATH} "C:\\windows" OUTPUT_VARIABLE WINE_LIBRARY_PATH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
FOREACH( RUNTIME_FILE ${INSTALL_RUNTIME_FILES} ${EXTERNAL_RUNTIME_LIBRARIES})
IF( RUNTIME_FILE)
GET_FILENAME_COMPONENT( LIBRARY_FILE_NAME ${RUNTIME_FILE} NAME)
EXECUTE_PROCESS( COMMAND ln -s -f "${RUNTIME_FILE}" "${WINE_LIBRARY_PATH}/system32/${LIBRARY_FILE_NAME}")
MESSAGE( STATUS "Executing ln -s -f ${RUNTIME_FILE} ${WINE_LIBRARY_PATH}/system32/${LIBRARY_FILE_NAME}")
ENDIF()
ENDFOREACH()
ENDIF()
ENDIF()
IF( INSTALL_RUNTIME_FILES)
MESSAGE( STATUS "found runtime files to install: ${INSTALL_RUNTIME_FILES}")
IF( MINGW)
INSTALL(
FILES ${INSTALL_RUNTIME_FILES}
DESTINATION ${BCL_EXTERN_DESTINATION}
COMPONENT BclReleaseAll
)
ELSEIF( UNIX)
FOREACH( INSTALL_RUNTIME_FILE ${INSTALL_RUNTIME_FILES})
MACRO_GET_SO_NAME( ${INSTALL_RUNTIME_FILE})
INSTALL(
FILES ${INSTALL_RUNTIME_FILE}
DESTINATION ${BCL_EXTERN_DESTINATION}
RENAME ${SO_FILE_NAME}
COMPONENT BclReleaseAll
)
UNSET( SO_FILE_NAME)
ENDFOREACH()
ENDIF()
ENDIF()
ENDIF()