File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,13 @@ target_link_options(${PROJECT_NAME} PRIVATE
119
119
$< $< OR:${IS_CLANG} ,${IS_GNU} > :
120
120
-static-libgcc
121
121
-static-libstdc++
122
+ >
123
+ # reading up on RPATH this is only relevant for unix based systems
124
+ # https://stackoverflow.com/questions/107888/is-there-a-windows-msvc-equivalent-to-the-rpath-linker-flag
125
+ # Is probably worth putting it behind another guard in the future.
126
+ # It appears that gcc silently ignores it on windows
127
+ # It's also probably unnecessary to be explicitly stated as CMake has a target property for it.
128
+ $< ${IS_GNU} :
122
129
-Wl,-R,'$$ORIGIN'
123
130
>
124
131
)
Original file line number Diff line number Diff line change @@ -15,10 +15,15 @@ else()
15
15
message (FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME} " )
16
16
endif ()
17
17
18
+ set ( IS_CLANG "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>" )
19
+ set ( IS_GNU "$<CXX_COMPILER_ID:GNU>" )
20
+ set ( IS_MSVC "$<CXX_COMPILER_ID:MSVC>" )
21
+
22
+
18
23
# Define our godot-cpp library
19
24
add_library (${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL )
20
25
21
- target_sources ( ${PROJECT_NAME}
26
+ target_sources (${PROJECT_NAME}
22
27
PRIVATE
23
28
src/example.cpp
24
29
src/example.h
@@ -27,13 +32,34 @@ target_sources( ${PROJECT_NAME}
27
32
src/tests.h
28
33
)
29
34
30
- target_link_libraries ( ${PROJECT_NAME}
35
+ target_link_libraries (${PROJECT_NAME}
31
36
PRIVATE
32
37
godot::cpp )
33
38
39
+ target_compile_options (${PROJECT_NAME}
40
+ PRIVATE
41
+ $< $< OR:${IS_CLANG} ,${IS_GNU} > :
42
+ -fPIC
43
+ -Wwrite-strings
44
+ >
45
+ )
46
+
47
+ target_link_options ( ${PROJECT_NAME}
48
+ PRIVATE
49
+ $< $< OR:${IS_CLANG} ,${IS_GNU} > :
50
+ -static-libgcc
51
+ -static-libstdc++
52
+ >
53
+ $< ${IS_GNU} : # see comments in the cmake/common_compiler_flags.cmake
54
+ -Wl,-R,'$$ORIGIN'
55
+ >
56
+ )
57
+
34
58
set_target_properties ( ${PROJECT_NAME}
35
59
PROPERTIES
36
60
OUTPUT_NAME "gdexample"
61
+ POSITION_INDEPENDENT_CODE ON
62
+ BUILD_RPATH_USE_ORIGIN ON
37
63
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} /bin/${TARGET_PATH}
38
64
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} /bin/${TARGET_PATH}
39
65
)
You can’t perform that action at this time.
0 commit comments