[CMake] Question about generate a source file during the build
Olaf Peter
ope-devel at gmx.de
Sun Feb 3 07:51:01 EST 2013
Hi,
I've read the FAQ hopefully carefully. But I did run into a problem with
a out-of-source-build:
---8<---
project(coolcoding)
# generate coolcoding's static lexer
set(COOLCODING_BAR_HPP
${PROJECT_BINARY_DIR}/include/foo/io/coolcoding/coolcoding_bar.hpp)
add_executable(generate_coolcoding_bar generate_coolcoding_bar.cpp)
add_custom_command(
OUTPUT ${COOLCODING_BAR_HPP}
COMMAND generate_coolcoding_bar ${COOLCODING_BAR_HPP}
)
add_custom_target(coolcoding_dfa DEPENDS ${COOLCODING_BAR_HPP})
set_source_files_properties(${COOLCODING_BAR_HPP} PROPERTIES GENERATED 1)
--->8---
The generation failed due to the fact, that I want to generate into
${PROJECT_BINARY_DIR}/include/foo/io/ the header.
The source file simply holds:
---8<---
int main(int argc, char* argv[])
{
...
std::ofstream out(argc < 2 ? "coolcoding_bar.hpp" : argv[1]);
...
--->8---
What is the recommended way the generate header not in the source-build
dir self (means where the generate_coolcoding_bar.cpp is placed)?
For the project self I have therefore to include $source/include and
$build/include.
Thanks,
Olaf
More information about the CMake
mailing list