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

CMake error when using with vcpkg #24

Open
observant2 opened this issue Jan 15, 2021 · 0 comments
Open

CMake error when using with vcpkg #24

observant2 opened this issue Jan 15, 2021 · 0 comments

Comments

@observant2
Copy link

observant2 commented Jan 15, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant