[CMake] Adding CMAKE_BUILD_TYPE support to ProjectConfig.cmake

Mateusz Loskot mateusz at loskot.net
Wed Dec 18 08:41:09 EST 2013


On 17 December 2013 14:27, J Decker <d3ck0r at gmail.com> wrote:
> which is... build seperately into seperate directories even with makefile.
> [...]

Yes, and that is a good feature of CMake.
What is still unclear to me is how the package registry works in such case.

Here is the basic example to support my previous question:

A library project:

/FooBar/
/FooBar/CMakeLists.txt
/FooBar/FooBarConfig.cmake

build in two variants:

cd /FooBar-build-debug
cmake -DCMAKE_BUILD_TYPE=Debug ../FooBar
cd /FooBar-build-release
cmake -DCMAKE_BUILD_TYPE=Release ../FooBar

A library client project with approach to structure and builds:

/FooBarUser/CMakeLists.txt
cd /FooBarUser-build-debug
cmake -DCMAKE_BUILD_TYPE=Debug ../FooBarUser
cd /FooBarUser-build-release
cmake -DCMAKE_BUILD_TYPE=Release ../FooBarUser

In /FooBarUser/CMakeLists.txt, there is find_package(FooBar)
which is supposed to look for FooBar in my local
package registry ~/.cmake to find FooBar from its build tree
(here, I'm interested in development workflow w/o installation).

Here come my questions":


Which FooBar build is picked?
How does CMake decide to pick one or another?
How do I configure CMakeLists.txt of FooBar and FooBarUser
so this command building FooBarUser client
picks FooBar from  /FooBar-build-debug

cmake -DCMAKE_BUILD_TYPE=Debug ../FooBarUser

and this picks FooBar from  /FooBar-build-release

cmake -DCMAKE_BUILD_TYPE=Release ../FooBarUser

?

Hopefully, I've managed to clarify what I'm asking about.

Best regards,
-- 
Mateusz  Łoskot, http://mateusz.loskot.net


More information about the CMake mailing list