-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
55 lines (45 loc) · 1.88 KB
/
CMakeLists.txt
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
# CMakeList.txt : CMake project for SDL_cmake_template, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.7.2)
project(SDL_cmake_template)
set(CMAKE_CXX_STANDARD 11)
# TODO: Add tests and install targets if needed.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(BIN_DIR ${SDL_cmake_template_SOURCE_DIR}/bin)
# This path is used by FindSDL2 module.
# It will find include and lib folders under this directory.
# This is because find command doesn't include any path for Windows.
# So it can't find anything using default paths.
# SDL2_PATH is already expected in module file. I'm using the same variable.
IF (WIN32)
set(SDL2_PATH "D:/CodeLibraries/SDL2/SDL2-2.0.9")
ENDIF()
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
set(SOURCE_FILES "src/main.cpp")
add_executable(SDL_cmake_template
${SOURCE_FILES}
)
target_link_libraries(SDL_cmake_template
${SDL2_LIBRARY}
)
install(TARGETS SDL_cmake_template RUNTIME DESTINATION ${BIN_DIR}/)
set_target_properties(SDL_cmake_template PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BIN_DIR}/debug/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BIN_DIR}/release/ )
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_custom_command( TARGET SDL_cmake_template POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SDL2_PATH}/lib/x64/SDL2.dll
${BIN_DIR}/debug/SDL2.dll )
add_custom_command( TARGET SDL_cmake_template POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SDL2_PATH}/lib/x64/SDL2.dll
${BIN_DIR}/debug/SDL2.dll )
elseif()
add_custom_command( TARGET SDL_cmake_template POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SDL2_PATH}/lib/x86/SDL2.dll
${BIN_DIR}/debug/SDL2.dll )
add_custom_command( TARGET SDL_cmake_template POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SDL2_PATH}/lib/x86/SDL2.dll
${BIN_DIR}/debug/SDL2.dll )
endif()