2019-10-15 01:51:50 +00:00
|
|
|
###############################################################################
|
|
|
|
## Author: Shaun Reed ##
|
|
|
|
## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ##
|
|
|
|
## ##
|
|
|
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
|
|
|
##############################################################################
|
|
|
|
# Root CMakeLists.txt of cpp practice 4-inheritance
|
|
|
|
|
|
|
|
# Define CMake version
|
|
|
|
cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
|
|
|
project( # Define project
|
|
|
|
inheritance # Project name
|
|
|
|
DESCRIPTION "Example project for class inheritance"
|
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
|
|
|
|
|
|
|
# Pass this to program to control debug output
|
|
|
|
option (DB_CONF "Should we debug and configure files with cmake values?" ON)
|
|
|
|
option (DB_BUILD "Should we run the build in debug mode?" OFF)
|
|
|
|
option (EXE_BUILD "Should we build the executable?" ON)
|
|
|
|
|
|
|
|
add_library( # Add Library
|
2021-04-28 03:42:12 +00:00
|
|
|
lib-sdl-test # Library Name
|
|
|
|
"src/lib-sdl-test.cpp" # Sources..
|
|
|
|
"src/lib-sdl-test.h"
|
2019-10-15 01:51:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories( # When calling library, include a directory
|
2021-04-28 03:42:12 +00:00
|
|
|
lib-sdl-test # Library name
|
2019-10-15 01:51:50 +00:00
|
|
|
PUBLIC #
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library
|
|
|
|
)
|
|
|
|
|
|
|
|
if (EXE_BUILD)
|
|
|
|
set(BUILD_STATUS "Building default executable")
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_search_module(SDL2 REQUIRED sdl2)
|
|
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
add_executable( # Creating executable
|
2021-04-28 03:42:12 +00:00
|
|
|
sdl-test # Exe name
|
|
|
|
"apps/sdl-test.cpp" # Exe Source(s)
|
2019-10-15 01:51:50 +00:00
|
|
|
)
|
|
|
|
target_link_libraries( # Linking the exe to library
|
2021-04-28 03:42:12 +00:00
|
|
|
sdl-test # Executable to link
|
|
|
|
PRIVATE #
|
|
|
|
lib-sdl-test # Library to link
|
2019-10-15 01:51:50 +00:00
|
|
|
${SDL2_LIBRARIES}
|
|
|
|
)
|
|
|
|
elseif(DB_BUILD)
|
|
|
|
set(BUILD_STATUS "Building in debug mode")
|
|
|
|
|
|
|
|
# Create compile_commands.json for linter
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS})
|
|
|
|
elseif(DB_CONF)
|
|
|
|
set(BUILD_STATUS "Building in debug mode, configuring files")
|
|
|
|
|
|
|
|
# Configure header file with CMake variables defined in src/lib-inherit.h.in
|
|
|
|
# @ONLY is specified, only variables of the form @VAR@ will be replaced and ${VAR} will be ignored.
|
|
|
|
# configure_file(src/lib-inherit.h src/lib-inherit.h @ONLY)
|
2021-04-28 03:42:12 +00:00
|
|
|
configure_file(apps/sdl-test.cpp apps/sdl-test.cpp @ONLY)
|
2019-10-15 01:51:50 +00:00
|
|
|
|
|
|
|
# Create compile_commands.json for linter
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
endif()
|
|
|
|
#target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS})
|
|
|
|
|