Skip to content

Commit

Permalink
CMake: Moving options below project declaration (#2047)
Browse files Browse the repository at this point in the history
* move options below project declaration

* expand cmake version dep for c++20 modules

* default VULKAN_HPP_GENERATOR_BUILD to PROJECT_IS_TOP_LEVEL

* fixed format

* moved CMAKE_CXX_STANDARD

* only set cxx standard if top-level
  • Loading branch information
M2-TE authored Jan 21, 2025
1 parent ce439ad commit e7a8252
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

if ( NOT CMAKE_CXX_STANDARD )
cmake_minimum_required( VERSION 3.12 )
project( VulkanHppGenerator LANGUAGES CXX )

if( CMAKE_VERSION VERSION_LESS "3.21" )
# https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html
string( COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL )
endif()

if ( PROJECT_IS_TOP_LEVEL )
set( CMAKE_CXX_STANDARD 11 )
endif()

# all the options for this project
option( VULKAN_HPP_PRECOMPILE "Precompile vulkan.hpp and vulkan_raii.hpp for sample builds" ON )
option( VULKAN_HPP_RUN_GENERATOR "Run the HPP generator" OFF )
option( VULKAN_HPP_GENERATOR_BUILD "Build the HPP generator" ON )
option( VULKAN_HPP_GENERATOR_BUILD "Build the HPP generator" ${PROJECT_IS_TOP_LEVEL} )
option( VULKAN_HPP_SAMPLES_BUILD "Build samples" OFF )
option( VULKAN_HPP_TESTS_BUILD "Build tests" OFF )
option( VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC "Build only dynamic. Required in case the Vulkan SDK is not available" OFF )
Expand All @@ -41,14 +49,14 @@ option( VULKAN_HPP_ENABLE_CPP20_MODULES "Build Vulkan-Hpp as C++20 module; requi
option( VULKAN_HPP_ENABLE_STD_MODULE "Build Vulkan-Hpp with import std; requires minimum CMake version 3.30" OFF )
option( VULKAN_HPP_CPP20_MODULE_DYNAMIC_DISPATCHER "Build C++20 module with dynamic Dispatcher" ON )

if ( VULKAN_HPP_ENABLE_CPP20_MODULES )
cmake_minimum_required( VERSION 3.28 )
else()
cmake_minimum_required( VERSION 3.12 )
if( VULKAN_HPP_ENABLE_CPP20_MODULES )
if( VULKAN_HPP_ENABLE_STD_MODULE AND CMAKE_VERSION VERSION_LESS "3.30")
message( FATAL_ERROR "Vulkan-Hpp: C++20 modules with import std require CMake 3.30 or later" )
elseif ( CMAKE_VERSION VERSION_LESS "3.28" )
message( FATAL_ERROR "Vulkan-Hpp: C++20 modules require CMake 3.28 or later" )
endif()
endif()

project( VulkanHppGenerator LANGUAGES CXX )

function( vulkan_hpp__setup_platform )
set( options )
set( oneValueArgs NAME )
Expand Down

0 comments on commit e7a8252

Please sign in to comment.