[CMake] add_custom_command, MAIN_DEPENDENCY, multiple targets, and Visual Studio
James Bigler
jamesbigler at gmail.com
Wed May 20 12:46:50 EDT 2009
I want to have the same file produce different output files and have the
same MAIN_DEPENDENCY.
project("My Prog")
cmake_minimum_required(VERSION 2.6)
add_custom_command(OUTPUT file1.obj
MAIN_DEPENDENCY source.cpp
COMMAND buildit -o file1.obj source.cpp
COMMENT "Making file1 from source"
)
add_custom_command(OUTPUT file2.obj
MAIN_DEPENDENCY source.cpp
COMMAND buildit -o file2.obj source.cpp
COMMENT "Making file2 from source"
)
set_source_files_properties(file1.obj file2.obj
PROPERTIES
EXTERNAL_OBJECT true # This is an object file not to be compiled, but only
be linked.
GENERATED true # Not an error if this file doesn't exist at the
start of build.
)
add_executable(prog1 source.cpp)
add_executable(prog2 source.cpp)
In Visual Studio I see this:
Solution 'My Proj'
+ All Build
- prog1
- Source Files
source.cpp -> Outputs file1.obj
CMakeLists.txt
- prog2
- Source Files
source.cpp -> Outputs file1.obj instead of file2.obj
CMakeLists.txt
+ ZERO_CHECK
Is it a limitation with Visual Studio or with CMake?
Note that if I add file1.obj and file2.obj to the project I get this:
Solution 'My Proj'
+ All Build
- prog1
- Source Files
source.cpp -> Outputs file1.obj
CMakeLists.txt
file1.obj -> no custom build step
- prog2
- CMake Rules
file2.obj.rule -> Outputs file2.obj
- Source Files
source.cpp -> Outputs file1.obj instead of file2.obj
CMakeLists.txt
file2.obj -> no custom build step
+ ZERO_CHECK
Thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090520/bbf7e3d6/attachment.htm>
More information about the CMake
mailing list