[CMake] Creating a custom target on Windows - strange problem
Arjen Markus
arjen.markus at wldelft.nl
Tue Sep 12 12:34:20 EDT 2006
Hello all,
in the PLplot project I have run into the following problem:
to test the build against one set of examples we need to copy them at CMake
configuration time into the build directory. All seems to go well, but when
the actual makefiles are generated I get error messages about CMake not
being able to create the files.
I have isolated the problem by creating two separate directories:
- src: with the CMakeLists.txt file and a single example (x02.tcl)
- build: to build the example (effectively to copy x02.tcl into that
directory).
Here is the CMakeListst.txt file (stripped down):
set(DATA_DIR data)
set(BUILD_TEST ON)
set(tcl_STRING_INDICES
"02"
)
set(tcl_SCRIPTS)
foreach(STRING_INDEX ${tcl_STRING_INDICES})
set(tcl_FILES ${tcl_FILES} x${STRING_INDEX}.tcl)
set(tcl_SCRIPTS ${tcl_SCRIPTS} x${STRING_INDEX})
endforeach(STRING_INDEX ${tcl_STRING_INDICES})
set(tclIndex_DEPENDS ${tcl_FILES} ${tcl_SCRIPTS})
set(tclIndex_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(BUILD_TEST AND
NOT CMAKE_CURRENT_BINARY_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}"
)
# equivalent to install commands but at "make" time rather than
# "make install" time, to the build tree if different than the source
# tree.
foreach(file ${tcl_SCRIPTS} ${tcl_FILES})
add_custom_target(${CMAKE_CURRENT_BINARY_DIR}/${file} ALL
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_CURRENT_BINARY_DIR}
)
message(STATUS ${CMAKE_CURRENT_BINARY_DIR}/${file})
endforeach(file ${tcl_SCRIPTS} ${tcl_FILES})
endif(BUILD_TEST AND
NOT CMAKE_CURRENT_BINARY_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}"
)
When I run this in ..\build, using
cmake -G "NMake makefiles" ..\src
I get the following output:
C:\arjen\plplot-5.6.1-cmake\testcbs\build>c:\arjen\cmake\install\bin\debug\cmake-G "NMake Makefiles" ..\src
-- Check for CL compiler version
-- Check for CL compiler version - 1200
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - no
-- Check CL platform
-- Check CL platform - 32 bit
-- Check for working C compiler: cl
-- Check for working C compiler: cl -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: cl
-- Check for working CXX compiler: cl -- works
-- C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02
-- C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02.tcl
-- Configuring done
CMake Error: Cannot open file for write:
C:/arjen/plplot-5.6.1-cmake/testcbs/build/CMakeFiles/C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02.dir/build.make.tmpCMake Error: : System Error: Invalid argument
CMake Error: Cannot open file for write:
C:/arjen/plplot-5.6.1-cmake/testcbs/build/CMakeFiles/C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02.tcl.dir/build.make.tmpCMake Error: : System Error: Invalid argument
-- Generating done
CMake Error: Cannot open file for write:
C:/arjen/plplot-5.6.1-cmake/testcbs/build/CMakeFiles/C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02.dir/progress.make.tmpCMake Error: : System Error: Invalid argument
CMake Error: Cannot open file for write:
C:/arjen/plplot-5.6.1-cmake/testcbs/build/CMakeFiles/C:/arjen/plplot-5.6.1-cmake/testcbs/build/x02.tcl.dir/progress.make.tmpCMake Error: : System Error: Invalid argument
-- Build files have been written to:
C:/arjen/plplot-5.6.1-cmake/testcbs/build
Clearly the path is all wrong (note the C:/arjen/... appearing twice)
- but I can not see how this is generated from the CMakeLists.txt file.
Can anyone solve this riddle?
Regards,
Arjen
More information about the CMake
mailing list