cmake_minimum_required(VERSION 2.6) project(pssp) ### Set directories # Set include directory include_directories(src) # Set an output directory for our binaries set(BIN_DIR ${pssp_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++17") 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} "${pssp_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(pssp ${SRC_DIR}) #Link executable against SDL2 and its extensions target_link_libraries(pssp stdc++fs ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_TTF_LIBRARY} ${SDL2_MIXER_LIBRARY}) install(TARGETS pssp RUNTIME DESTINATION ${BIN_DIR})