cmake_minimum_required(VERSION 3.14) project(BlogCodeListings VERSION 1.0) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Toggle production build option(PRODUCTION_BUILD "Make this a production build" OFF) # Debug configuration if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") else() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") endif() include(FetchContent) # Add nlohmann/json dependency FetchContent_Declare( json GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.10.4 ) FetchContent_MakeAvailable(json) # Define the BlogCodeListing library file(GLOB_RECURSE ClientSources "src/*.cpp") file(GLOB_RECURSE ClientHeaders "src/*.h") add_library(GameLibrary STATIC ${ClientSources} ${ClientHeaders} # Helps with IDE navigation ) target_include_directories(GameLibrary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${json_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/vendor/lua_5.4.2/include ) target_link_libraries(GameLibrary PUBLIC ${CMAKE_SOURCE_DIR}/vendor/lua_5.4.2/lua54.lib ) # ---------- # Executable # ---------- add_executable(BlogCodeListing src/Main.cpp ) target_link_libraries(BlogCodeListing PUBLIC GameLibrary ) if(PRODUCTION_BUILD) target_compile_definitions(GameLibrary PUBLIC RESOURCES_PATH="./resources/") target_compile_definitions(GameLibrary PUBLIC PRODUCTION_BUILD=1) set_target_properties(BlogCodeListing PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/BlogCodeListing ) add_custom_command(TARGET BlogCodeListing POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $/resources ) else() target_compile_definitions(GameLibrary PUBLIC RESOURCES_PATH="${PROJECT_SOURCE_DIR}/resources/") target_compile_definitions(GameLibrary PUBLIC PRODUCTION_BUILD=0) endif()