Re: [CMake] Circular dependencies because of file names?

2011-11-17 Thread Michael Hertling
On 11/16/2011 06:36 PM, Jookia wrote:
 I've actually used that workaround, but it seems dirty as it shows up in 
 IDE targets like Visual Studio or other IDEs or makefiles. In fact, I 
 kind of like the 'generating /docs' part of the makefile.
 
 Would it just be smarter to rename the target to 'documentation'?

Of course, that's also possible, but then, the documentation target and
the documentation directory would not be named the same. Alternatively,
you might leave out the WORKING_DIRECTORY clause, add another COMMAND
cmake -E make_directory to the target and use cmake -E chdir:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(DOCS NONE)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_CUSTOM_TARGET(docs
COMMAND ${CMAKE_COMMAND} -E
make_directory ${CMAKE_BINARY_DIR}/docs
COMMAND ${CMAKE_COMMAND} -E
chdir ${CMAKE_BINARY_DIR}/docs pwd)

Presumably, the directory's additional creations carries no weight.

Regards,

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Circular dependencies because of file names?

2011-11-16 Thread Jookia
I've actually used that workaround, but it seems dirty as it shows up in 
IDE targets like Visual Studio or other IDEs or makefiles. In fact, I 
kind of like the 'generating /docs' part of the makefile.


Would it just be smarter to rename the target to 'documentation'?
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Circular dependencies because of file names?

2011-11-15 Thread Michael Hertling
On 11/14/2011 09:31 PM, Jookia wrote:
 I have the following code:
 
 # -- DOXYGEN
 
 find_package(Doxygen)
 
 set(docsDir ${CMAKE_BINARY_DIR}/docs/)
 
 add_custom_command(OUTPUT ${docsDir}
COMMAND ${CMAKE_COMMAND} -E make_directory
${docsDir} VERBATIM)
 
 add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE}
${CMAKE_SOURCE_DIR}/../doxygen/doxyfile
WORKING_DIRECTORY ${docsDir}
DEPENDS ${docsDir})
 
 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
${docsDir})
 
 Which causes a circular conflict. But when I change the docsDir to 
 ${CMAKE_BINARY_DIR}/docs2/, I no longer get the error.
 
 Is there a way to fix this?

The docs custom command is integrated in the docs custom target's
Makefile with a relative path, so there are dependencies of the type
docs (custom target) on docs (custom command's output) which are
ignored by Make. Thus, the docs directory is not created, and the
custom target fails. In general, it's a bad idea to have targets
with the same name as files/directories they depend on.

In order to solve this issue, add another custom target, say, docdir
which depends on the custom command's output; this will decouple the
docs custom target from the custom command. Finally, establish the
dependency of docs on docdir by ADD_DEPENDENCIES():

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(DOCS NONE)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/docs
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs)
ADD_CUSTOM_TARGET(docdir DEPENDS ${CMAKE_BINARY_DIR}/docs)
ADD_CUSTOM_TARGET(docs
COMMAND ${CMAKE_COMMAND} -E echo custom target docs
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docs)
ADD_DEPENDENCIES(docs docdir)

Regards,

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake