|
@@ -3,6 +3,8 @@
|
|
|
cmake_minimum_required(VERSION 3.12)
|
|
|
project(sdl_test LANGUAGES C)
|
|
|
|
|
|
+include(GenerateExportHeader)
|
|
|
+
|
|
|
if(ANDROID)
|
|
|
macro(add_executable NAME)
|
|
|
set(args ${ARGN})
|
|
@@ -41,6 +43,12 @@ if(TEST_SHARED)
|
|
|
)
|
|
|
endif()
|
|
|
|
|
|
+ add_library(sharedlib-shared SHARED main_lib.c)
|
|
|
+ target_link_libraries(sharedlib-shared PRIVATE SDL2::SDL2)
|
|
|
+ generate_export_header(sharedlib-shared EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
|
|
|
+ target_compile_definitions(sharedlib-shared PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared_export.h\"")
|
|
|
+ set_target_properties(sharedlib-shared PROPERTIES C_VISIBILITY_PRESET "hidden")
|
|
|
+
|
|
|
add_executable(gui-shared-vars WIN32 main_gui.c)
|
|
|
target_link_libraries(gui-shared-vars PRIVATE ${SDL2_LIBRARIES})
|
|
|
target_include_directories(gui-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|
|
@@ -60,6 +68,13 @@ if(TEST_SHARED)
|
|
|
target_link_libraries(cli-shared-vars PRIVATE ${SDL2_LIBRARIES})
|
|
|
target_include_directories(cli-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|
|
|
endif()
|
|
|
+
|
|
|
+ add_library(sharedlib-shared-vars SHARED main_lib.c)
|
|
|
+ target_link_libraries(sharedlib-shared-vars PRIVATE ${SDL2_LIBRARIES})
|
|
|
+ target_include_directories(sharedlib-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|
|
|
+ generate_export_header(sharedlib-shared-vars EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
|
|
|
+ target_compile_definitions(sharedlib-shared-vars PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared-vars_export.h\"")
|
|
|
+ set_target_properties(sharedlib-shared-vars PROPERTIES C_VISIBILITY_PRESET "hidden")
|
|
|
endif()
|
|
|
|
|
|
if(TEST_STATIC)
|
|
@@ -73,6 +88,15 @@ if(TEST_STATIC)
|
|
|
endif()
|
|
|
target_link_libraries(gui-static PRIVATE SDL2::SDL2-static)
|
|
|
|
|
|
+ option(SDL_STATIC_PIC "SDL static library has been built with PIC")
|
|
|
+ if(SDL_STATIC_PIC OR WIN32)
|
|
|
+ add_library(sharedlib-static SHARED main_lib.c)
|
|
|
+ target_link_libraries(sharedlib-static PRIVATE SDL2::SDL2-static)
|
|
|
+ generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
|
|
|
+ target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"")
|
|
|
+ set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
|
|
|
+ endif()
|
|
|
+
|
|
|
add_executable(gui-static-vars WIN32 main_gui.c)
|
|
|
target_link_libraries(gui-static-vars PRIVATE ${SDL2MAIN_LIBRARY} ${SDL2_STATIC_LIBRARIES})
|
|
|
target_include_directories(gui-static-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|