diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e0084c..524f8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.7 FATAL_ERROR) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +find_package(ECM REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin/release") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin/debug") @@ -37,20 +40,26 @@ target_link_libraries(openVulkanoCpp PRIVATE glfw) endif() # glm -add_subdirectory(external/glm EXCLUDE_FROM_ALL) -target_link_libraries(openVulkanoCpp PRIVATE glm) +include_directories(external/glm) # fmt #add_subdirectory(external/fmt EXCLUDE_FROM_ALL) #target_link_libraries(openVulkanoCpp PRIVATE fmt) # spdlog -add_subdirectory(external/spdlog EXCLUDE_FROM_ALL) -target_link_libraries(openVulkanoCpp PRIVATE spdlog) +include_directories(external/spdlog/include) #add_definitions(-SPDLOG_FMT_EXTERNAL) # assimp -add_subdirectory(external/assimp EXCLUDE_FROM_ALL) -target_link_libraries(openVulkanoCpp PRIVATE assimp) +include_directories(external/assimp) +IF(WIN32) + find_library(ASSIMP_LIBRARIES NAMES assimp libassimp.dll.a PATHS ${CMAKE_SOURCE_DIR}/libs/assimp) +ELSE(WIN32) + find_package(ASSIMP REQUIRED) +ENDIF(WIN32) -target_sources(openVulkanoCpp PRIVATE openVulkanoCpp/Vulkan/FrameBuffer.cpp) \ No newline at end of file +target_sources(openVulkanoCpp PRIVATE openVulkanoCpp/Vulkan/FrameBuffer.cpp openVulkanoCpp/Base/Logger.cpp openVulkanoCpp/Scene/Drawable.cpp openVulkanoCpp/Scene/Node.cpp) + +# copy shaders +file(GLOB SHADERS "openVulkanoCpp/Shader/*.spv") +file(COPY ${SHADERS} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Shader/) \ No newline at end of file diff --git a/cmake/modules/FindASSIMP.cmake b/cmake/modules/FindASSIMP.cmake new file mode 100644 index 0000000..8b9b580 --- /dev/null +++ b/cmake/modules/FindASSIMP.cmake @@ -0,0 +1,56 @@ +# Find assimp +# Copyright © 2016 Dylan Baker + +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Provides a subset of what the one would get by calling CONFIG REQUIRED +# directly, it will unset any unsupported versions +# Currently it provides the following: +# ASSIMP_FOUND -- TRUE if assimp was found +# ASSIMP_LIBRARIES -- Libraries to link against + +find_package(ASSIMP CONFIG) +if (ASSIMP_LIBRARIES) + # Unset variables that would be difficult to get via the find module + unset(ASSIMP_ROOT_DIR) + unset(ASSIMP_CXX_FLAGS) + unset(ASSIMP_LINK_FLAGS) + unset(ASSIMP_Boost_VERSION) + + # TODO: It would be nice to find these, but they're not being used at the + # moment. They also need to be added to REQUIRED_VARS if added + unset(ASSIMP_INCLUDE_DIRS) + unset(ASSIMP_LIBRARY_DIRS) + + # Like the found path + set(ASSIMP_FOUND TRUE) + message("-- Found ASSIMP") +else () + find_library(ASSIMP_LIBRARIES + NAMES assimp + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + ASSIMP + REQUIRED_VARS ASSIMP_LIBRARIES + ) +endif (ASSIMP_LIBRARIES) + +set(ASSIMP_FOUND True) diff --git a/cmake/modules/FindXCB.cmake b/cmake/modules/FindXCB.cmake new file mode 100644 index 0000000..89ed904 --- /dev/null +++ b/cmake/modules/FindXCB.cmake @@ -0,0 +1,51 @@ +# - FindXCB +# +# Copyright 2015 Valve Coporation + +find_package(PkgConfig) + +if(NOT XCB_FIND_COMPONENTS) + set(XCB_FIND_COMPONENTS xcb) +endif() + +include(FindPackageHandleStandardArgs) +set(XCB_FOUND true) +set(XCB_INCLUDE_DIRS "") +set(XCB_LIBRARIES "") +foreach(comp ${XCB_FIND_COMPONENTS}) + # component name + string(TOUPPER ${comp} compname) + string(REPLACE "-" "_" compname ${compname}) + # header name + string(REPLACE "xcb-" "" headername xcb/${comp}.h) + # library name + set(libname ${comp}) + + pkg_check_modules(PC_${comp} QUIET ${comp}) + + find_path(${compname}_INCLUDE_DIR NAMES ${headername} + HINTS + ${PC_${comp}_INCLUDEDIR} + ${PC_${comp}_INCLUDE_DIRS} + ) + + find_library(${compname}_LIBRARY NAMES ${libname} + HINTS + ${PC_${comp}_LIBDIR} + ${PC_${comp}_LIBRARY_DIRS} + ) + + find_package_handle_standard_args(${comp} + FOUND_VAR ${comp}_FOUND + REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY) + mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY) + + list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR}) + list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY}) + + if(NOT ${comp}_FOUND) + set(XCB_FOUND false) + endif() +endforeach() + +list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS) \ No newline at end of file diff --git a/openVulkanoCpp/main.cpp b/openVulkanoCpp/main.cpp index f729ad1..ebfbdf3 100644 --- a/openVulkanoCpp/main.cpp +++ b/openVulkanoCpp/main.cpp @@ -28,7 +28,7 @@ public: cam.Init(70, 16, 9, 0.1f, 100); scene.SetCamera(&cam); cam.SetMatrix(glm::translate(glm::mat4(1), glm::vec3(0,0,-10))); - shader.Init("Shader\\basic", "Shader\\basic"); + shader.Init("Shader/basic", "Shader/basic"); drawablesPool.resize(GEOS); for(int i = 0; i < GEOS; i++) {