Mario: add sdlpp as a subdirectory instead of ExternalProject

This commit is contained in:
zvon 2021-08-05 18:00:47 +02:00
parent 509e5e36c2
commit 8e566ddb03

View File

@ -3,7 +3,6 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
enable_language(CXX) enable_language(CXX)
include(ExternalProject)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
@ -19,20 +18,8 @@ list(APPEND CommonFiles
mario.cpp mario.cpp
blocks.cpp blocks.cpp
) )
set(SDLPPDir ${CMAKE_CURRENT_SOURCE_DIR}/../sdlpp)
add_library(sdlpp STATIC IMPORTED) add_subdirectory(../sdlpp sdlpp)
set_target_properties(sdlpp PROPERTIES
IMPORTED_LOCATION libsdlpp.a
)
ExternalProject_Add(sdlpp_external
SOURCE_DIR ${SDLPPDir}
CONFIGURE_COMMAND ""
BUILD_COMMAND make libsdlpp.a
BUILD_IN_SOURCE 1
INSTALL_COMMAND install -m 644 "${SDLPPDir}/libsdlpp.a" ${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(mario add_executable(mario
${CommonFiles} ${CommonFiles}
@ -53,10 +40,8 @@ add_executable(editor
) )
target_compile_definitions(editor PUBLIC EDITOR) target_compile_definitions(editor PUBLIC EDITOR)
target_link_libraries(mario PRIVATE sdlpp)
target_link_libraries(editor PRIVATE sdlpp)
target_link_libraries(mario PRIVATE SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads) target_link_libraries(mario PRIVATE sdlpp SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads)
target_link_libraries(editor PRIVATE SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads) target_link_libraries(editor PRIVATE sdlpp SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testfont.ttf ${CMAKE_CURRENT_SOURCE_DIR}/sprites DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testfont.ttf ${CMAKE_CURRENT_SOURCE_DIR}/sprites DESTINATION ${CMAKE_CURRENT_BINARY_DIR})