Closed JonathanGirardeau closed 2 months ago
I have finally found how to deal with relative path with CMake.
I changed my code to:
INCBIN(myData, "config-schema.json");
And for:
target_include_directories(${PROJECT_NAME} PRIVATE resources)
in CMakeLists.txt
if(MSVC)
add_custom_command(OUTPUT data.c
COMMAND incbin_tool
ARGS -I${CMAKE_CURRENT_LIST_DIR} -I${CMAKE_CURRENT_LIST_DIR}/resources ${SOURCES} -o ${CMAKE_BINARY_DIR}/data.c
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMENT "Generating resources with incbin_tool")
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/data.c)
endif()
Hi, I develop code that is built on windows with MSVC and on linux with GCC. I use CMake.
I use the "tool" on windows to generate data.c but my problem is I can't find a way to express relative path that works with MSVC and GCC:
It seems that with GCC the path has to be relative to the build directory and with MSVC the path has to be relative to the current working directory when the build command is executed.