Re: [CMake] overriding ${PROJECTNAME}_BINARY_DIR before call to project()

2011-09-28 Thread Michael Hertling
On 09/28/2011 06:36 PM, Thomas Wolf wrote:
> On 28.09.2011 17:58, Jean-Christophe Fillion-Robin wrote:
>> Hi Thomas,
>>
>> You will find below few points that should help you to address your issues:
>>
>> 1) CTK build system can be build with the option CTK_SUPERBUILD set to
>> OFF, in that case the project will be built as a "regular" cmake project.
>>
>> 2) You could also build CTK normally (default option) providing VTK_DIR,
>> Log4Qt_DIR etc ... the CTK build system will understand these
>> dependencies are available and no project will be downloaded. This is
>> somehow equivalent to build CTK with CTK_SUPERBUILB OFF
>>
>> 3) If you want to make sure all binaries and libs are built in a custom
>> location, make sure you set:
>>
>> CTK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY
>> CTK_CMAKE_LIBRARY_OUTPUT_DIRECTORY
>>
>>
>> CTK_CMAKE_RUNTIME_OUTPUT_DIRECTORY
>>
>> Seehttps://github.com/commontk/CTK/blob/master/CMakeLists.txt#L91
>>
>> Would be great if you could send request regarding CTK to
>> ctk-develop...@commontk.org 
>> More info here: http://www.commontk.org and
>> http://www.commontk.org/index.php/Getting_Started
>>
>> Thanks
>> Jc
>>
> 
> Hello Jean-Christophe,
> 
> thanks for your reply. Actually, i took CTK just as an example for the 
> problem, but i will also try what you suggested.
> 
> CTK_SUPERBUILD is already off.
> 
> Anyway I wonder why ${PROJ}_BINARY_DIR is not settable for me.

You *can* set a subproject's binary directory by using the binary_dir
parameter of ADD_SUBDIRECTORY(); see the following exemplary project:

# CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(BINDIR C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_SUBDIRECTORY(subdir1 ${CMAKE_BINARY_DIR}/bindir)
ADD_SUBDIRECTORY(subdir2)

# subdir1/CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(SUBDIR1 C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/f1.c "void f1(void){}\n")
ADD_LIBRARY(f1 SHARED f1.c)
MESSAGE("${PROJECT_NAME}_BINARY_DIR: ${${PROJECT_NAME}_BINARY_DIR}")

# subdir2/CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(SUBDIR2 C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/f2.c "void f2(void){}\n")
ADD_LIBRARY(f2 SHARED f2.c)
MESSAGE("${PROJECT_NAME}_BINARY_DIR: ${${PROJECT_NAME}_BINARY_DIR}")

As you can see during the configuration, the subproject in subdir1 will
be built in ${CMAKE_BINARY_DIR}/bindir while the essentially identical
subproject in subdir2 will be built in ${CMAKE_BINARY_DIR}/subdir2 as
usual. However, CMake doesn't allow two or more subprojects to share
a common build directory, i.e. you can't say

ADD_SUBDIRECTORY(subdir2 ${CMAKE_BINARY_DIR}/bindir)

too, and with regard to CMakeFiles, Makefile, cmake_install.cmake
etc., this would be anyway a recipe for desaster. Thus, each of your
subprojects must be provided with an individual build directory, and
to collect your targets' binaries in the top-level CMAKE_BINARY_DIR,
you may use the diverse *_OUTPUT_DIRECTORY[_] properties and
the corresponding CMAKE_*_OUTPUT_DIRECTORY variables. Alternatively,
you might add a custom target in the top-level CMakeLists.txt file:

ADD_CUSTOM_TARGET(binaries ALL
COMMAND ${CMAKE_COMMAND} -E copy $
 ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $
 ${CMAKE_BINARY_DIR}
COMMENT "Copying binaries to ${CMAKE_BINARY_DIR}"
)
ADD_DEPENDENCIES(binaries f1 f2)

'hope that helps.

Regards,

Michael

> Regards,
> Thomas
> 
> PS.: i posted also something on ctk-developers, but the posting didn't 
> appear.
--

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] overriding ${PROJECTNAME}_BINARY_DIR before call to project()

2011-09-28 Thread Thomas Wolf

On 28.09.2011 17:58, Jean-Christophe Fillion-Robin wrote:

Hi Thomas,

You will find below few points that should help you to address your issues:

1) CTK build system can be build with the option CTK_SUPERBUILD set to
OFF, in that case the project will be built as a "regular" cmake project.

2) You could also build CTK normally (default option) providing VTK_DIR,
Log4Qt_DIR etc ... the CTK build system will understand these
dependencies are available and no project will be downloaded. This is
somehow equivalent to build CTK with CTK_SUPERBUILB OFF

3) If you want to make sure all binaries and libs are built in a custom
location, make sure you set:

CTK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY
CTK_CMAKE_LIBRARY_OUTPUT_DIRECTORY


CTK_CMAKE_RUNTIME_OUTPUT_DIRECTORY

Seehttps://github.com/commontk/CTK/blob/master/CMakeLists.txt#L91

Would be great if you could send request regarding CTK to
ctk-develop...@commontk.org 
More info here: http://www.commontk.org and
http://www.commontk.org/index.php/Getting_Started

Thanks
Jc



Hello Jean-Christophe,

thanks for your reply. Actually, i took CTK just as an example for the 
problem, but i will also try what you suggested.


CTK_SUPERBUILD is already off.

Anyway I wonder why ${PROJ}_BINARY_DIR is not settable for me.

Regards,
Thomas

PS.: i posted also something on ctk-developers, but the posting didn't 
appear.

--

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] overriding ${PROJECTNAME}_BINARY_DIR before call to project()

2011-09-28 Thread Jean-Christophe Fillion-Robin
Hi Thomas,

You will find below few points that should help you to address your issues:

1) CTK build system can be build with the option CTK_SUPERBUILD set to OFF,
in that case the project will be built as a "regular" cmake project.

2) You could also build CTK normally (default option) providing VTK_DIR,
Log4Qt_DIR etc ... the CTK build system will understand these dependencies
are available and no project will be downloaded. This is somehow equivalent
to build CTK with CTK_SUPERBUILB OFF

3) If you want to make sure all binaries and libs are built in a custom
location, make sure you set:

CTK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY
CTK_CMAKE_LIBRARY_OUTPUT_DIRECTORY

CTK_CMAKE_RUNTIME_OUTPUT_DIRECTORY

See https://github.com/commontk/CTK/blob/master/CMakeLists.txt#L91

Would be great if you could send request regarding CTK to
ctk-develop...@commontk.org
More info here: http://www.commontk.org and
http://www.commontk.org/index.php/Getting_Started

Thanks
Jc

On Wed, Sep 28, 2011 at 11:35 AM, Thomas Wolf  wrote:

> Hi there,
>
> I have some serious trouble to get a makefile running, comprising of MITK,
> VTK, ITK, CTK, Log4Qt, DCMTK, GDCM, etc...
>
> Because most of the makefiles have some imperfections regarding being built
> under windows and x64 with the project environment of Visual Studio 2008, we
> use direct builds in the main makefile. This also helps to see all source
> code of the involved projects. The project requirements are also set in a
> way that we cannto use git or downloads, so the technique called
> "superbuild" is not applicable here.
>

> To get the involved projects to be built at the correct place, namely all
> created binaries in the CMAKE_BINARY_DIR location of the main makefile, i
> try to override e.g. CTK_BINARY_DIR before the inclusion of the CTK makefile
> via add_subdirectory.
>

> I have a hard time doing this, even with
>
> SET(CTK_BINARY_DIR ${CMAKE_BINARY_DIR} CACHE INTERNAL "" FORCE
> PARENT_SCOPE)
>
> the next call to project(CTK) overrides this and takes some other value.
> This value corresponds to the layout of the source tree apparently, but is
> of no use in this situation.
>
> How can I influence the value of CTK_BINARY_DIR before the call to the
> makefile?
>
> i tried to use project(CTK) in the toplevel makefile one directory up, but
> even then the values won't be taken.
>
> so this situation in
>
> mainmakefile:
>
> project(CTK)
> set(CTK_BINARY_DIR "some other place" CACHE INTERNAL "" FORCE PARENT_SCOPE
> )
> add_subdirectory(CTK)
>
> does not change a thing for CTK. Even when the CTK makefile (naturally)
> sets project(CTK), cmake does not complain or state something about double
> projects, but silently overwrites the CTK_BINARY_DIR with new values! So it
> respects the second call to 'project()', which in my opinion should be
> either
> a) reported as an error
> or
> b) the first call to project(CTK) should have priority
>
> Can someone help me?
>
> Regards,
> Thomas
> --
>
> 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
>



-- 
+1 919 869 8849
--

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

[CMake] overriding ${PROJECTNAME}_BINARY_DIR before call to project()

2011-09-28 Thread Thomas Wolf

Hi there,

I have some serious trouble to get a makefile running, comprising of 
MITK, VTK, ITK, CTK, Log4Qt, DCMTK, GDCM, etc...


Because most of the makefiles have some imperfections regarding being 
built under windows and x64 with the project environment of Visual 
Studio 2008, we use direct builds in the main makefile. This also helps 
to see all source code of the involved projects. The project 
requirements are also set in a way that we cannto use git or downloads, 
so the technique called "superbuild" is not applicable here.


To get the involved projects to be built at the correct place, namely 
all created binaries in the CMAKE_BINARY_DIR location of the main 
makefile, i try to override e.g. CTK_BINARY_DIR before the inclusion of 
the CTK makefile via add_subdirectory.


I have a hard time doing this, even with

SET(CTK_BINARY_DIR ${CMAKE_BINARY_DIR} CACHE INTERNAL "" FORCE PARENT_SCOPE)

the next call to project(CTK) overrides this and takes some other value. 
This value corresponds to the layout of the source tree apparently, but 
is of no use in this situation.


How can I influence the value of CTK_BINARY_DIR before the call to the 
makefile?


i tried to use project(CTK) in the toplevel makefile one directory up, 
but even then the values won't be taken.


so this situation in

mainmakefile:

project(CTK)
set(CTK_BINARY_DIR "some other place" CACHE INTERNAL "" FORCE PARENT_SCOPE )
add_subdirectory(CTK)

does not change a thing for CTK. Even when the CTK makefile (naturally)
sets project(CTK), cmake does not complain or state something about 
double projects, but silently overwrites the CTK_BINARY_DIR with new 
values! So it respects the second call to 'project()', which in my 
opinion should be either

a) reported as an error
or
b) the first call to project(CTK) should have priority

Can someone help me?

Regards,
Thomas
--

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