Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

CMake error when using with vcpkg #24

Description

@observant2

Hi!
Thank you for these great in depth tutorials!

I am using vcpkg in Visual Studio by default and no one except vcpkg is allowed to redefine add_executable, otherwise you're stuck in an infitie recursion, because add_executable calls itself.

The error is:

1> [CMake]   Maximum recursion depth of 1000 exceeded

Here are the necessary fixes to the CMakeLists.txt:

macro( my_add_executable _type _number _name )
	set( TARGET_NAME "${_number}-${_name}" )
	file( GLOB PROJECT_FILES "${CMAKE_CURRENT_LIST_DIR}/${_type}/${_number}/*.*" )
	add_executable( ${TARGET_NAME} ${ARGN} ${PROJECT_FILES} )
	target_compile_definitions( ${TARGET_NAME} PRIVATE USE_SWAPCHAIN_EXTENSIONS )
	target_link_libraries( ${TARGET_NAME} ${PLATFORM_LIBRARY} )
	set_property( TARGET ${TARGET_NAME} PROPERTY FOLDER "${_type}" )

	if( EXISTS "${CMAKE_SOURCE_DIR}/${_type}/${_number}/Data" )
		file( GLOB DATA_FILES "${CMAKE_SOURCE_DIR}/${_type}/${_number}/Data/*.*" )
		file( COPY ${DATA_FILES} DESTINATION "${CMAKE_SOURCE_DIR}/build/Data/${_type}/${_number}/" )
	endif()
endmacro()

# ...

add_executable( "01-The_Beginning" ${ALL_BASIC_SHARED_FILES}
	Tutorials/01/Tutorial01.h
	Tutorials/01/main.cpp
	Tutorials/01/Tutorial01.cpp )

target_link_libraries( "01-The_Beginning" ${PLATFORM_LIBRARY} )
set_property( TARGET "01-The_Beginning" PROPERTY FOLDER "Tutorials" )

my_add_executable( "Tutorials" "02" "Swapchain" ${ALL_BASIC_SHARED_FILES} )

my_add_executable( "Tutorials" "03" "First_Triangle" ${ALL_BASIC_AND_ADVANCED_SHARED_FILES} )

my_add_executable( "Tutorials" "04" "Vertex_Attributes" ${ALL_BASIC_AND_ADVANCED_SHARED_FILES} )

my_add_executable( "Tutorials" "05" "Staging_Resources" ${ALL_BASIC_AND_ADVANCED_SHARED_FILES} )

my_add_executable( "Tutorials" "06" "Descriptor_Sets" ${ALL_BASIC_AND_ADVANCED_SHARED_FILES} )

my_add_executable( "Tutorials" "07" "Uniform_Buffers" ${ALL_BASIC_AND_ADVANCED_SHARED_FILES} )

So basically just rename add_executable to something else. Maybe you find a more fitting name than my_add_executable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions