Add basic project setup with engine and editor subdirectories
This commit is contained in:
@@ -1,44 +1,54 @@
|
|||||||
|
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
||||||
|
|
||||||
project(Example)
|
project(nova)
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_compile_options(
|
# Configuration Options
|
||||||
|
set(NOVA_BUILD_ENGINE ON CACHE BOOL "Build the engine")
|
||||||
|
set(NOVA_BUILD_EDITOR ON CACHE BOOL "Build the editor")
|
||||||
|
set(NOVA_ENGINE_SHARED ON CACHE BOOL "Build the engine as a shared library")
|
||||||
|
set(NOVA_ENGINE_STATIC OFF CACHE BOOL "Build the engine as a static library")
|
||||||
|
set(NOVA_EDITOR_STATIC OFF CACHE BOOL "Link the editor against the engine statically")
|
||||||
|
|
||||||
|
if (NOVA_BUILD_EDITOR)
|
||||||
|
if (NOVA_EDITOR_STATIC)
|
||||||
|
set(NOVA_BUILD_ENGINE ON)
|
||||||
|
set(NOVA_ENGINE_STATIC ON)
|
||||||
|
else ()
|
||||||
|
set(NOVA_ENGINE_SHARED ON)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
add_compile_options(
|
||||||
|
/W3
|
||||||
|
/permissive-
|
||||||
|
/EHsc
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
add_compile_options(
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
-Wpedantic
|
-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
|
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(run
|
if (WIN32)
|
||||||
COMMAND ${PROJECT_NAME}
|
add_compile_definitions(
|
||||||
DEPENDS ${PROJECT_NAME}
|
_CRT_SECURE_NO_WARNINGS
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
NOMINMAX
|
||||||
)
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOVA_BUILD_ENGINE)
|
||||||
|
add_subdirectory(engine)
|
||||||
|
endif ()
|
||||||
|
if (NOVA_BUILD_EDITOR)
|
||||||
|
add_subdirectory(editor)
|
||||||
|
endif ()
|
||||||
|
|||||||
28
LICENSE
Normal file
28
LICENSE
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2025, Jayden Grubb
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
34
editor/CMakeLists.txt
Normal file
34
editor/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
set(SRC
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
list(TRANSFORM SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||||
|
|
||||||
|
add_executable(nova-editor ${SRC})
|
||||||
|
|
||||||
|
target_include_directories(nova-editor PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
${CMAKE_SOURCE_DIR}/engine/include
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOVA_EDITOR_STATIC)
|
||||||
|
target_link_libraries(nova-editor PRIVATE
|
||||||
|
nova_static
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
target_link_libraries(nova-editor PRIVATE
|
||||||
|
nova
|
||||||
|
)
|
||||||
|
target_compile_definitions(nova-editor PRIVATE
|
||||||
|
NOVA_DLL_IMPORT
|
||||||
|
)
|
||||||
|
if (CMAKE_IMPORT_LIBRARY_SUFFIX)
|
||||||
|
add_custom_command(TARGET nova-editor POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:nova-editor> $<TARGET_FILE_DIR:nova-editor>
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
11
editor/src/main.cpp
Normal file
11
editor/src/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <nova/test.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
func();
|
||||||
|
}
|
||||||
24
engine/CMakeLists.txt
Normal file
24
engine/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
set(SRC
|
||||||
|
test.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
list(TRANSFORM SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
${Vulkan_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOVA_ENGINE_SHARED)
|
||||||
|
add_library(nova SHARED ${SRC})
|
||||||
|
target_compile_definitions(nova PRIVATE
|
||||||
|
NOVA_DLL_EXPORT
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
if (NOVA_ENGINE_STATIC)
|
||||||
|
add_library(nova_static STATIC ${SRC})
|
||||||
|
endif ()
|
||||||
25
engine/include/nova/api.h
Normal file
25
engine/include/nova/api.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NOVA_API
|
||||||
|
#ifdef WIN32
|
||||||
|
#ifdef NOVA_DLL_EXPORT
|
||||||
|
#define NOVA_API __declspec(dllexport)
|
||||||
|
#elif NOVA_DLL_IMPORT
|
||||||
|
#define NOVA_API __declspec(dllimport)
|
||||||
|
#else
|
||||||
|
#define NOVA_API
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef NOVA_DLL_EXPORT
|
||||||
|
#define NOVA_API __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define NOVA_API
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
11
engine/include/nova/test.h
Normal file
11
engine/include/nova/test.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nova/api.h>
|
||||||
|
|
||||||
|
NOVA_API void func();
|
||||||
13
engine/src/test.cpp
Normal file
13
engine/src/test.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <nova/test.h>
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
void func() {
|
||||||
|
std::printf("Hello, world!\n");
|
||||||
|
}
|
||||||
12
src/main.cpp
12
src/main.cpp
@@ -1,12 +0,0 @@
|
|||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
std::printf("Hello, World!\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++) {
|
|
||||||
std::printf("argv[%d] = %s\n", i, argv[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user