Skip to content

cmake script is requested #2

Description

@mmj-the-fighter

sample working cmake script:

# set project
cmake_minimum_required(VERSION 3.14)
project(ChessGameSolution)
set(GAME chess_game)
#---------------------------------------------
# set standards
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)
#---------------------------------------------
# SDL3 
# fetch SDL3 from internet
include(FetchContent)

FetchContent_Declare(
    SDL3
    GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
    GIT_TAG        release-3.2.0
    GIT_SHALLOW    TRUE
)
FetchContent_MakeAvailable(SDL3)
#---------------------------------------------
# Spinach
# Collect C++ source files for spinach
file(GLOB_RECURSE SPN_CPP_SRC CONFIGURE_DEPENDS
    Libraries/Spinach/spinach/common/*.cpp
    Libraries/Spinach/spinach/core/*.cpp
)


# Collect C sources for spinach
file(GLOB_RECURSE SPN_C_SRC CONFIGURE_DEPENDS
    Libraries/Spinach/spinach/external/stb/*.c
)

# Collect headers 
file(GLOB_RECURSE SPN_H CONFIGURE_DEPENDS
    Libraries/Spinach/spinach/common/*.h
    Libraries/Spinach/spinach/common/*.hpp
    Libraries/Spinach/spinach/core/*.h
    Libraries/Spinach/spinach/core/*.hpp
    Libraries/Spinach/spinach/external/stb/*.h
)
# ------------------------------------
# 1. Game
# Collect C++ source files
file(GLOB_RECURSE CHG_CPP_SRC CONFIGURE_DEPENDS
    Board/*.cpp
	CommandSystem/*.cpp
	Core/*.cpp
	Game/*.cpp
    Pieces/*.cpp
	Utils/*.cpp
)

file(GLOB CHG_MAIN_SRC CONFIGURE_DEPENDS
    main.cpp
)

# Collect headers 
file(GLOB_RECURSE CHG_CPP_H CONFIGURE_DEPENDS
    Board/*.h
	CommandSystem/*.h
	Core/*.h
	Game/*.h
    Pieces/*.h
	Utils/*.h
)

# Create the executable
add_executable(	${GAME}
	${CHG_MAIN_SRC}
	${CHG_CPP_SRC}
	${SPN_CPP_SRC}
    ${SPN_C_SRC}
    ${CHG_CPP_H} 
	${SPN_H}
)

target_include_directories(${GAME} PRIVATE
	Libraries/Spinach/spinach/common
    Libraries/Spinach/spinach/core
    Libraries/Spinach/spinach/external/stb/
	Board
	CommandSystem
	Core
	Game
    Pieces
	Utils
)


target_link_libraries(${GAME} PRIVATE SDL3::SDL3)

# ------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions