-
Notifications
You must be signed in to change notification settings - Fork 4
/
SDL.cmake
63 lines (51 loc) · 1.66 KB
/
SDL.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
include(ExternalProject)
set(SDL_VERSION "2.0.9")
set(SDL_VERSION_STRING "SDL2-${SDL_VERSION}")
set(SDL_ROOT_DIR "${EXTERN_DIR}/${SDL_VERSION_STRING}")
set(SDL_MSVC_DIR "${SDL_ROOT_DIR}/VisualC")
if(OS_WINDOWS)
set(CONFIGURE_COMMAND "")
set(BUILD_COMMAND
MSBuild
"${SDL_MSVC_DIR}/SDL.sln"
/p:PlatformToolset=v142 # Default: v100
/p:Configuration=${CMAKE_BUILD_TYPE}
/p:Platform=x64
/m)
set(BUILD_BYPRODUCTS
"${SDL_MSVC_DIR}/x64/${CMAKE_BUILD_TYPE}/SDL2.lib"
"${SDL_MSVC_DIR}/x64/${CMAKE_BUILD_TYPE}/SDL2main.lib")
install(
FILES "${SDL_MSVC_DIR}/x64/${CMAKE_BUILD_TYPE}/SDL2.dll"
DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
if(OS_MACOSX)
set(CONFIGURE_COMMAND ./configure)
set(BUILD_COMMAND make
COMMAND install_name_tool
-id
"@executable_path/../Frameworks/libSDL2-2.0.0.dylib"
"${SDL_ROOT_DIR}/build/.libs/libSDL2-2.0.0.dylib")
set(BUILD_BYPRODUCTS
"${SDL_ROOT_DIR}/build/.libs/libSDL2-2.0.0.dylib"
"${SDL_ROOT_DIR}/build/.libs/libSDL2main.a")
install(
FILES "${SDL_ROOT_DIR}/build/.libs/libSDL2-2.0.0.dylib"
DESTINATION "${CMAKE_INSTALL_PREFIX}/CompositeEngine.app/Contents/Frameworks")
endif()
ExternalProject_Add(
SDLExternal
PREFIX ${SDL_VERSION_STRING}
DOWNLOAD_DIR ${EXTERN_DIR}
URL "https://www.libsdl.org/release/${SDL_VERSION_STRING}.tar.gz"
SOURCE_DIR ${SDL_ROOT_DIR}
BINARY_DIR ${SDL_ROOT_DIR}
CONFIGURE_COMMAND "${CONFIGURE_COMMAND}"
BUILD_COMMAND "${BUILD_COMMAND}"
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS}
)
add_library(SDL INTERFACE)
add_dependencies(SDL SDLExternal)
target_include_directories(SDL INTERFACE "${SDL_ROOT_DIR}/include")
target_link_libraries(SDL INTERFACE ${BUILD_BYPRODUCTS})