forked from krystiankaluzny/Tanks
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
40 lines (32 loc) · 2.02 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
cmake_minimum_required (VERSION 3.0.0)
#run from build folder as: cmake -G "NMake Makefiles" ..
#can specify -DCMAKE_GENERATOR_PLATFORM=x64 in command line, or do: set(CMAKE_GENERATOR_PLATFORM x64)
#but similar like -A WIN32, this is not allowed for "NMake Makefiles" generator, so use customized var
set(lib_platform x64)
project(Tanks)
include_directories(SDL/include)
link_directories(SDL/lib/${lib_platform})
link_libraries(SDL2main.lib SDL2.lib SDL2_image.lib SDL2_ttf.lib SDL2_mixer.lib)
#set(EXECUTABLE_OUTPUT_PATH ./${CMAKE_BUILD_TYPE})
set(EXECUTABLE_OUTPUT_PATH out) #set RUNTIME_OUTPUT_DIRECTORY doesn't work as expected
#add_subdirectory(src)
file(
GLOB_RECURSE
MY_SOURCE_FILES
src/*
)
#as https://cmake.org/Bug/view.php?id=15703 copy with wildcart and path doesn't work, supposed fixed?
#or shell/Windows console issue? For now, ignore this, just manually copy over the dlls
#file(COPY ${PROJECT_SOURCE_DIR}/SDL/lib/${lib_platform}/*.dll DESTINATION ${EXECUTABLE_OUTPUT_PATH})
file(COPY ${PROJECT_SOURCE_DIR}/resources/levels DESTINATION ${EXECUTABLE_OUTPUT_PATH})
file(COPY ${PROJECT_SOURCE_DIR}/resources/sounds DESTINATION ${EXECUTABLE_OUTPUT_PATH})
file(COPY ${PROJECT_SOURCE_DIR}/resources/png/texture.png DESTINATION ${EXECUTABLE_OUTPUT_PATH})
file(COPY ${PROJECT_SOURCE_DIR}/resources/font/prstartk.ttf DESTINATION ${EXECUTABLE_OUTPUT_PATH})
add_executable(${PROJECT_NAME} ${MY_SOURCE_FILES}) # do not specify WIN32 as conflict with SDL2main
# Below only works for copying file generated by build
#add_custom_command(TARGET Tanks POST_BUILD # Adds a post-build event to project Tanks
# COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
# "${PROJECT_SOURCE_DIR}/SDL/lib/${lib_platform}/*.dll" # <--this is in-file
# ${EXECUTABLE_OUTPUT_PATH}) # <--this is out-file path
#"NMake install" will install to system path, which is not desired here
#install(TARGETS Tanks CONFIGURATIONS Release RUNTIME DESTINATION subdir_under_program_files_proj)