diff --git a/.gitignore b/.gitignore index 984bf650..ba14b481 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .vs/ bin/ bin-int/ +*build*/ # Files *.vcxproj diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..28fe4fd3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required (VERSION 3.13) + +project(Walnut) + +find_package(Vulkan REQUIRED) + +# TODO: Figure out how to allow later standards +if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +add_subdirectory(vendor) +add_subdirectory(Walnut) +add_subdirectory(WalnutApp) diff --git a/Walnut/CMakeLists.txt b/Walnut/CMakeLists.txt new file mode 100644 index 00000000..5bc06210 --- /dev/null +++ b/Walnut/CMakeLists.txt @@ -0,0 +1,25 @@ +file(GLOB_RECURSE Walnut_SRC LIST_DIRECTORIES false src/*.cpp) + +add_library(Walnut STATIC ${Walnut_SRC}) +target_include_directories(Walnut PUBLIC src) +# set_property(TARGET Walnut PROPERTY POSITION_INDEPENDENT_CODE ON) + +# setup internal project compile definition +if(WIN32) + target_compile_definitions(Walnut PRIVATE WL_PLATFORM_WINDOWS) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_definitions(Walnut PRIVATE WL_DEBUG) +elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + target_compile_definitions(Walnut PRIVATE WL_RELEASE) +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_definitions(Walnut PRIVATE WL_DIST) +endif() + +target_link_libraries(Walnut PUBLIC imgui glfw glm::glm stb_image Vulkan::Vulkan) +if(WIN32) + target_link_libraries(Walnut PUBLIC dwmapi) +endif() + +install(TARGETS Walnut DESTINATION bin) diff --git a/Walnut/src/Walnut/EntryPoint.h b/Walnut/src/Walnut/EntryPoint.h index 8e88cffb..a44a1c74 100644 --- a/Walnut/src/Walnut/EntryPoint.h +++ b/Walnut/src/Walnut/EntryPoint.h @@ -1,7 +1,5 @@ #pragma once -#ifdef WL_PLATFORM_WINDOWS - extern Walnut::Application* Walnut::CreateApplication(int argc, char** argv); bool g_ApplicationRunning = true; @@ -21,7 +19,7 @@ namespace Walnut { } -#ifdef WL_DIST +#if defined(WL_DIST) && defined(WL_PLATFORM_WINDOWS) #include @@ -37,6 +35,4 @@ int main(int argc, char** argv) return Walnut::Main(argc, argv); } -#endif // WL_DIST - -#endif // WL_PLATFORM_WINDOWS +#endif // WL_DIST && WL_PLATFORM_WINDOWS diff --git a/WalnutApp/CMakeLists.txt b/WalnutApp/CMakeLists.txt new file mode 100644 index 00000000..1e5c96f8 --- /dev/null +++ b/WalnutApp/CMakeLists.txt @@ -0,0 +1,20 @@ +file(GLOB_RECURSE WalnutApp_SRC LIST_DIRECTORIES false src/*.cpp) + +add_executable(WalnutApp ${WalnutApp_SRC}) +target_include_directories(WalnutApp PRIVATE src) +target_link_libraries(WalnutApp PRIVATE Walnut) + +# setup internal project compile definition +if(WIN32) + target_compile_definitions(Walnut PRIVATE WL_PLATFORM_WINDOWS) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_definitions(WalnutApp PRIVATE WL_DEBUG) +elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + target_compile_definitions(WalnutApp PRIVATE WL_RELEASE) +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_definitions(WalnutApp PRIVATE WL_DIST) +endif() + +install(TARGETS WalnutApp DESTINATION bin) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt new file mode 100644 index 00000000..a0d5680e --- /dev/null +++ b/vendor/CMakeLists.txt @@ -0,0 +1,16 @@ +# Setup vendor libraries +## IMGUI (No CMake support, we have to roll or own) +set(imgui_SRC imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp imgui/imgui_widgets.cpp imgui/imgui_demo.cpp) +add_library(imgui STATIC ${imgui_SRC}) +target_include_directories(imgui PUBLIC imgui) +set_property(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON) + +## GLFW (comes with its own CMakeLists, let's use that) +add_subdirectory(GLFW) + +## glm (comes with its own CMakeLists, let's use that) +add_subdirectory(glm) + +## stb_image (header-only, create a dummy interface library) +add_library(stb_image INTERFACE) +target_include_directories(stb_image INTERFACE stb_image)