@@ -65,14 +65,28 @@ endif ()
6565# to the library structure later on will encounter issues caused by the
6666# generative nature of the project.
6767message ("Generating Traits with openassetio-traitgen" )
68+
69+ # Locate the openassetio-traitgen executable. This allows the user to
70+ # override which traitgen is used via CMake mechanisms, e.g.
71+ # CMAKE_PREFIX_PATH, or by directly setting
72+ # OPENASSETIO_TRAITGEN_EXECUTABLE.
73+ find_program (
74+ OPENASSETIO_TRAITGEN_EXECUTABLE
75+ NAMES openassetio-traitgen
76+ REQUIRED
77+ )
78+ message (STATUS "Found openassetio-traitgen at: ${OPENASSETIO_TRAITGEN_EXECUTABLE} " )
79+
6880# Mark the traits source as a configure dependency by copying it to the
6981# binary dir, and use that file to run traitgen from.
7082# This means if the source traits file is changed, configure will rerun.
7183configure_file (${CMAKE_CURRENT_LIST_DIR } /traits.yml ${PROJECT_BINARY_DIR } /traits.yml )
72- execute_process (COMMAND openassetio-traitgen ${PROJECT_BINARY_DIR } /traits.yml
73- -o ${PROJECT_BINARY_DIR } /cpp -g cpp
74- COMMAND_ERROR_IS_FATAL ANY
75- COMMAND_ECHO STDERR )
84+ execute_process (
85+ COMMAND ${OPENASSETIO_TRAITGEN_EXECUTABLE} ${PROJECT_BINARY_DIR } /traits.yml
86+ -o ${PROJECT_BINARY_DIR } /cpp -g cpp
87+ COMMAND_ERROR_IS_FATAL ANY
88+ COMMAND_ECHO STDERR
89+ )
7690
7791if (OPENASSETIO_MEDIACREATION_GENERATE_PYTHON)
7892 # Generate the python package by running traitgen.
@@ -87,10 +101,12 @@ if (OPENASSETIO_MEDIACREATION_GENERATE_PYTHON)
87101 # `pip install .` (and invoking setup.py), but that's not a
88102 # guarentee going forward, as additional elements of the python
89103 # package may be added to mediacreation.
90- execute_process (COMMAND openassetio-traitgen ${PROJECT_BINARY_DIR } /traits.yml
104+ execute_process (
105+ COMMAND ${OPENASSETIO_TRAITGEN_EXECUTABLE} ${PROJECT_BINARY_DIR } /traits.yml
91106 -o ${PROJECT_BINARY_DIR } /python -g python
92107 COMMAND_ERROR_IS_FATAL ANY
93- COMMAND_ECHO STDERR )
108+ COMMAND_ECHO STDERR
109+ )
94110endif ()
95111
96112add_library (openassetio-mediacreation INTERFACE )
0 commit comments