platform-test/CMakeLists.txt

63 lines
2.1 KiB
CMake

cmake_minimum_required(VERSION 2.6)
project(platform-test)
### Set directories
# Set include directory
include_directories(src)
# Set an output directory for our binaries
set(BIN_DIR ${platform-test_SOURCE_DIR})
# Set sources dir
file(GLOB_RECURSE SRC_DIR RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp")
# Bump up warning levels appropriately for clang, gcc & msvc
# Also set debug/optimization flags depending on the build type.
# IDE users choose this when selecting the build mode in their IDE
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()
### Find SFML stuff
# Use our modified FindSDL2* modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${platform-test_SOURCE_DIR}/cmake")
# Look up SDL2 and add the include directory to our include path
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
# Look up SDL2_Image and add the include directory to our include path
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_IMAGE_INCLUDE_DIR})
# Look up SDL2_TTF and add the include directory to our include path
find_package(SDL2_ttf REQUIRED)
include_directories(${SDL2_TTF_INCLUDE_DIR})
# Look up SDL2_mixer and add the include directory to our include path
find_package(SDL2_mixer REQUIRED)
include_directories(${SDL2_MIXER_INCLUDE_DIR})
#### Binaries
# Make executable and indclude all the sources
add_executable(platform-test ${SRC_DIR})
#Link executable against SDL2 and its extensions
target_link_libraries(platform-test ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_TTF_LIBRARY} ${SDL2_MIXER_LIBRARY})
install(TARGETS platform-test RUNTIME DESTINATION ${BIN_DIR})