[CMake] Depending on a Config File (CMake and VC++)
Steve Johns
steve.johns at verizon.net
Fri May 26 15:47:59 EDT 2006
> There was a typo in my example: it should not have the comma between the
> arguments. The trailing comma is being considered part of the file name!
Great eye, Brad!
So, here what I have now:
IF(CMAKE_CONFIGURATION_TYPES)
# Handle multi-configuration generators.
FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/traps_config.txt
${CMAKE_CURRENT_BINARY_DIR}/${config}/traps_config.txt
COPYONLY)
ENDFOREACH(config)
ELSE(CMAKE_CONFIGURATION_TYPES)
# Handle single-configuration generators.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/traps_config.txt
${CMAKE_CURRENT_BINARY_DIR}/traps_config.txt COPYONLY)
ENDIF(CMAKE_CONFIGURATION_TYPES)
and here is what happens:
-- Configuring done
-- Generating done
CMake Error: Unknown Target referenced : traps_config.txt
CMake Error: Target: traps depends on unknown target: traps_config.txt
this happens with both in-source and out-of-source builds.
> Be careful with this. For an in-source build this may not work. That is
> why my original example included a ".in" extension on the input file.
I don't really understand that part but I did try this, as an experiment
IF(CMAKE_CONFIGURATION_TYPES)
# Handle multi-configuration generators.
FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/traps_config.in
${CMAKE_CURRENT_BINARY_DIR}/${config}/traps_config.txt
COPYONLY)
ENDFOREACH(config)
ELSE(CMAKE_CONFIGURATION_TYPES)
# Handle single-configuration generators.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/traps_config.in
${CMAKE_CURRENT_BINARY_DIR}/traps_config.txt COPYONLY)
ENDIF(CMAKE_CONFIGURATION_TYPES)
with identical, failed results.
As I read the docs, we've asked the system to copy a file. The file is
there. I'm at a loss to see
why it doesn't just happen. Obviously, I have something more to learn here
...
More information about the CMake
mailing list