I’m new to CMake and I found this file.
set( EXAMPLE_DEMO_TARGET demo )
set ( USH_TARGET ush_demo )
build_ush ( ${USH_TARGET}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(
${USH_TARGET}
PUBLIC
USH_CONFIG_PLATFORM_POSIX
)
add_executable(
${EXAMPLE_DEMO_TARGET}
${CMAKE_CURRENT_SOURCE_DIR}/demo.c
${CMAKE_CURRENT_SOURCE_DIR}/interface.c
${CMAKE_CURRENT_SOURCE_DIR}/commands.c
${CMAKE_CURRENT_SOURCE_DIR}/terminal.c
${CMAKE_CURRENT_SOURCE_DIR}/shell.c
${CMAKE_CURRENT_SOURCE_DIR}/fs/fs.c
${CMAKE_CURRENT_SOURCE_DIR}/fs/path/root.c
${CMAKE_CURRENT_SOURCE_DIR}/fs/path/etc.c
${CMAKE_CURRENT_SOURCE_DIR}/fs/path/dev.c
${CMAKE_CURRENT_SOURCE_DIR}/fs/path/bin.c
)
target_link_libraries( ${EXAMPLE_DEMO_TARGET} PUBLIC ${USH_TARGET})
target_compile_options( ${EXAMPLE_DEMO_TARGET} PRIVATE -Werror -Wall -Wextra -g -O0)
Mostly my problem is with USH_TARGET
/ush_demo
. The first part that I don’t understand is this. Is it a function or something else and what does it do? I can see that it is not just another CMake command.
build_ush ( ${USH_TARGET}
${CMAKE_CURRENT_SOURCE_DIR}
)
This is other line that confused me because now it looks like ush_demo
is a library.
target_link_libraries( ${EXAMPLE_DEMO_TARGET} PUBLIC ${USH_TARGET})
In the generated Makefile I found this and now I don’t know what is the difference between demo
and ush_demo
.
# Target rules for targets named ush_demo
# Build rule for target.
ush_demo: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 ush_demo
.PHONY : ush_demo
# fast build rule for target.
ush_demo/fast:
$(MAKE) $(MAKESILENT) -f examples/demo_linux/CMakeFiles/ush_demo.dir/build.make examples/demo_linux/CMakeFiles/ush_demo.dir/build
.PHONY : ush_demo/fast
#=============================================================================
# Target rules for targets named demo
# Build rule for target.
demo: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 demo
.PHONY : demo
# fast build rule for target.
demo/fast:
$(MAKE) $(MAKESILENT) -f examples/demo_linux/CMakeFiles/demo.dir/build.make examples/demo_linux/CMakeFiles/demo.dir/build
.PHONY : demo/fast
At what point does ush_demo
become a target and what is the difference between it and demo
?
The full project is here.