Target API
bruxisma opened this issue · comments
Currently, there is no way for us to have a more cohesive and more coherent API for creating targets in a given project. Additionally, we need to worry about tools such as vcpkg overriding add_executable
amongst other commands. To reduce this chance, we can add a more generic target()
command, with a variety of dynamic subcommands. This will allow us to make some operations easier (such as implementing commands for the generate()
API), while also allowing us to signal users when a target is added or created within an IXM Blueprint. This would also allow us to generate ALIAS
targets in the same target creation call.
Currently planned targets include:
-
target(PROGRAM)
-- This isn't different fromadd_executable
but is more inline with CMake naming conventions -
target(LIBRARY)
-- This will useadd_library(SHARED)
call, to keep up with CMake's naming conventions -
target(ARCHIVE)
-- This will useadd_library(STATIC)
, and keep up with CMake's naming conventions -
target(UNITY)
-- This will generate both a unity build file, and a library viaadd_library(OBJECT)
-
target(PLUGIN)
-- This will generate a module. This is done to keep C++ module andadd_library(MODULE)
separate so as to not confuse users. -
target(IMPORT)
-- This signature will be used to generate imported targets -
target(INTERFACE) --
add_library(INTERFACE)` -
target(TEST)
--add_test
wrapper -
target(PHONY)
--add_custom_target
wrapper. -
target(COMMAND)
--add_custom_command
wrapper. -
target(LIST)
-- Lists all targets for the current project or given subdirectory. Useful for debugging (though in practice is not provided by the Debug API)
We will also potentially have:
target(BUNDLE)
-- macOS bundle apptarget(FRAMEWORK)
-- macOS frameworktarget(TOOL)
-- liketarget(PROGRAM)
but will be compiled for the host if native compilation is ever supported under CMake's cross compilation model.target(SERVICE)
-- launchd/systemd related service
This list is subject to change but this currently works as a good start :)
We should also support declaring a target as part of a 'component'. This would let us organize targets into named components, which can be used for adding options to multiple targets at once, while also allowing CPack components to be "implicit" to some degree.
This was a complete nightmare and I had to rip it out in the end. The fewer targets you generate, the more well behaved CMake is 🤷♀️