Add basic project hierarchy and build config

This commit is contained in:
2025-11-01 00:39:18 +10:00
parent 572a83bce6
commit c6ac9a92ce
21 changed files with 95 additions and 47 deletions

View File

@@ -1,44 +1,64 @@
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
project(Example)
project(nova)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wold-style-cast
)
add_executable(
${PROJECT_NAME}
src/main.cpp
)
# find_package(Example REQUIRED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
# ${Example_INCLUDE_DIRS}
)
target_link_libraries(
${PROJECT_NAME}
# ${Example_LIBRARIES}
)
if (CMAKE_IMPORT_LIBRARY_SUFFIX)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND_EXPAND_LISTS
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(
/W4
/permissive-
/EHsc
)
endif ()
add_compile_definitions(
NOVA_COMPILER_MSVC
)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wold-style-cast
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(
NOVA_COMPILER_GCC
)
else()
add_compile_definitions(
NOVA_COMPILER_CLANG
)
endif()
else()
error("Unsupported compiler")
endif()
add_custom_target(run
COMMAND ${PROJECT_NAME}
DEPENDS ${PROJECT_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
if (WIN32)
add_compile_definitions(
NOVA_PLATFORM_WINDOWS
NOMINMAX
WIN32_LEAN_AND_MEAN
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_WARNINGS
)
elseif (APPLE)
add_compile_definitions(
NOVA_PLATFORM_MACOS
)
elseif (UNIX)
add_compile_definitions(
NOVA_PLATFORM_LINUX
)
else()
error("Unsupported platform")
endif()
add_subdirectory(engine)
add_subdirectory(editor)