[CMake] CMake script mode not backward compatible?

2018-10-29 Thread Damien R
Hi,

Since cmake 3.10, using cmake in script mode (-P) produce an error with the
following script:

cmake_minimum_required(VERSION 3.9)
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL FALSE)

I did not see something related in the release notes of cmake 3.10 so I
would like to know if it is a regression, or if I was lucky that it worked
in cmake prior to 3.10?

Damien R.
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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


[CMake] Auto generating package configuration file?

2018-02-14 Thread Damien R
Hi,

I know that I could write FooConfig.cmake.in, call
configure_package_config_file() to generate package configuration file and
call write_basic_package_version_file() to generate a version file.
Typically FooConfig.cmake.in contains:
@PACKAGE_INIT@
find_dependency(...)

My question is why do I need to do that? Is it not possible for cmake to
autogenerate theses files?
I may be wrong but I think that "modern cmake" has the necessary
informations to do that.

Regards,

Damien R.
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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


Re: [CMake] check_cxx_compiler_flag usage

2017-12-07 Thread Damien R
check_cxx_compiler_flag uses CMAKE_REQUIRED_DEFINITIONS. For me its means
that only "-DSOME_FLAG=VALUE" should be tested with this macro and I think
that the name is misleading.
Some people define CMAKE_REQUIRED_FLAGS / CMAKE_REQUIRED_LIBRARIES before
invoking check_cxx_compiler_flag but I think that they should use
check_cxx_source_compiles.
In your case I would use CMAKE_REQUIRED_FLAGS and check_cxx_source_compiles.

But as I am not the developer which has written this cmake code there may
be some points that invalidate what I just said.

Regards,

Damien R.


On 7 December 2017 at 15:13, Clément Gregoire  wrote:

> Your usage of check_cxx_compiler_flag is correct, it's probably just
> missing link flags or something.
> Can you check the error log of cmake to know why it fails to compile ? It
> is in your buildfolder : CMakeFiles/CMakeError.log
>
> Here's how I did it for coverage by the way (not perfect, but was enough
> for my usage):
>
> https://github.com/Lectem/cpp-boilerplate/blob/master/cmake/
> Coverage.cmake#L42
>
>
>
>
> 2017-12-07 14:31 GMT+01:00 Damien R :
>
>> Thank you for pointing that. It increments the number of people using
>> CMAKE_REQUIRED_FLAGS "trick" to make it working with
>> check_cxx_compiler_flag.
>>
>> But my question is more about :
>>  - why they coded CHECK_CXX_COMPILER_FLAG this way?
>>  - is my usage valid or not? If not what should I do? If yes, is it a bug?
>>
>> Regards,
>>
>> Damien R.
>>
>>
>>
>> On 7 December 2017 at 10:35, Eric Noulard  wrote:
>>
>>>
>>> Not really answering the question but
>>> did you try to use an existing CMake module for handling sanitizers
>>> config?
>>>
>>> I find this one https://github.com/arsenm/sanitizers-cmake very
>>> effective, with
>>> modern CMake target oriented features.
>>>
>>>
>>>
>>>
>>> 2017-12-07 9:24 GMT+01:00 Damien R :
>>>
>>>> Hi,
>>>>
>>>> I am trying to use CHECK_CXX_COMPILER_FLAG with cmake 3.9 to check if
>>>> the compiler supports asan.
>>>> The CMakeLists.txt is:
>>>> cmake_minimum_required(VERSION 3.9)
>>>> include(CheckCXXCompilerFlag)
>>>> check_cxx_compiler_flag("-fsanitize=address" COMPILER_SUPPORT_FLAG)
>>>>
>>>> I always got:
>>>> -- Performing Test COMPILER_SUPPORT_FLAG - Failed
>>>>
>>>> Even if the documentation say that CHECK_CXX_COMPILER_FLAG sets
>>>> CMAKE_REQUIRED_DEFINITIONS by the name of the macro I thought that it would
>>>> work.
>>>> Can you tell me why CHECK_CXX_COMPILER_FLAG use
>>>> CMAKE_REQUIRED_DEFINITIONS instead of CMAKE_REQUIRED_FLAGS
>>>> and what is the official way for checking this flag?
>>>>
>>>> Regards,
>>>>
>>>> Damien R.
>>>>
>>>>
>>>> --
>>>>
>>>> Powered by www.kitware.com
>>>>
>>>> Please keep messages on-topic and check the CMake FAQ at:
>>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>>
>>>> Kitware offers various services to support the CMake community. For
>>>> more information on each offering, please visit:
>>>>
>>>> CMake Support: http://cmake.org/cmake/help/support.html
>>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/cmake
>>>>
>>>
>>>
>>>
>>> --
>>> Eric
>>>
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] check_cxx_compiler_flag usage

2017-12-07 Thread Damien R
Thank you for pointing that. It increments the number of people using
CMAKE_REQUIRED_FLAGS "trick" to make it working with
check_cxx_compiler_flag.

But my question is more about :
 - why they coded CHECK_CXX_COMPILER_FLAG this way?
 - is my usage valid or not? If not what should I do? If yes, is it a bug?

Regards,

Damien R.



On 7 December 2017 at 10:35, Eric Noulard  wrote:

>
> Not really answering the question but
> did you try to use an existing CMake module for handling sanitizers config?
>
> I find this one https://github.com/arsenm/sanitizers-cmake very
> effective, with
> modern CMake target oriented features.
>
>
>
>
> 2017-12-07 9:24 GMT+01:00 Damien R :
>
>> Hi,
>>
>> I am trying to use CHECK_CXX_COMPILER_FLAG with cmake 3.9 to check if the
>> compiler supports asan.
>> The CMakeLists.txt is:
>> cmake_minimum_required(VERSION 3.9)
>> include(CheckCXXCompilerFlag)
>> check_cxx_compiler_flag("-fsanitize=address" COMPILER_SUPPORT_FLAG)
>>
>> I always got:
>> -- Performing Test COMPILER_SUPPORT_FLAG - Failed
>>
>> Even if the documentation say that CHECK_CXX_COMPILER_FLAG sets
>> CMAKE_REQUIRED_DEFINITIONS by the name of the macro I thought that it would
>> work.
>> Can you tell me why CHECK_CXX_COMPILER_FLAG use
>> CMAKE_REQUIRED_DEFINITIONS instead of CMAKE_REQUIRED_FLAGS
>> and what is the official way for checking this flag?
>>
>> Regards,
>>
>> Damien R.
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
>
> --
> Eric
>
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] check_cxx_compiler_flag usage

2017-12-07 Thread Damien R
Hi,

I am trying to use CHECK_CXX_COMPILER_FLAG with cmake 3.9 to check if the
compiler supports asan.
The CMakeLists.txt is:
cmake_minimum_required(VERSION 3.9)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fsanitize=address" COMPILER_SUPPORT_FLAG)

I always got:
-- Performing Test COMPILER_SUPPORT_FLAG - Failed

Even if the documentation say that CHECK_CXX_COMPILER_FLAG sets
CMAKE_REQUIRED_DEFINITIONS by the name of the macro I thought that it would
work.
Can you tell me why CHECK_CXX_COMPILER_FLAG use
CMAKE_REQUIRED_DEFINITIONS instead of CMAKE_REQUIRED_FLAGS
and what is the official way for checking this flag?

Regards,

Damien R.
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using a variable as a method name

2012-06-02 Thread Damien R
On 2 June 2012 12:16, Damien R  wrote:

> Hi, there is also a variation based on the workaround given by David:
>  ...
>

Sorry, this workaround was already found in the bug mentioned by David in
his last post (http://public.kitware.com/Bug/view.php?id=4034).
The problem is that the title of this bug make it difficult to find it in a
search engine ...

Regards,
Damien R.
--

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] Using a variable as a method name

2012-06-02 Thread Damien R
On 1 June 2012 17:22, David Cole  wrote:

> Not directly, but as a workaround, you could write that into a file, and
> then include the file.
>
> i.e.:
>
> file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tmp.cmake" "BAR_${FOO}(arg1 arg2)")
> include(${CMAKE_CURRENT_BINARY_DIR}/tmp.cmake)
>

Hi, there is also a variation based on the workaround given by David:

suppose you want to call:
bar_${foo1}(arg1 arg2)
bar_${foo2}(arg1 arg2)

you can create 2 files:
- bar1.cmake
macro(bar)
...
endmacro()

- bar2.cmake
macro(bar)
...
endmacro()

After that you can replace:
bar_${foo1}(arg1 arg2)
bar_${foo2}(arg1 arg2)
by:
include(${foo1}.cmake)
bar(...)
include(${foo2}.cmake)
bar(...)

where:
${foo1} = bar1
${foo2} = bar2

Regards,
Damien R.
--

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] Test organization within cmake

2012-05-24 Thread Damien R
Hi,

I want some help to organize tests within cmake.
Currently I have a test directory which contains some test files, eg :
test_foo.cpp
test_bar.cpp

In the CMakeLists.txt, I had:
add_executable(test_foo test_foo.cpp)
add_test(test_foo test_foo)

add_executable(test_bar test_bar.cpp)
add_test(test_bar test_bar)

test_bar and test_foo have not the same dependencies so I did:
find_package(Boost COMPONENTS thread)
add_executable(test_foo test_foo.cpp)
add_test(test_foo test_foo)
target_link_libraries(test_foo ${Boost_LIBRARIES} my-project)

find_package(Boost COMPONENTS system)
add_executable(test_bar test_bar.cpp)
add_test(test_bar test_bar)
target_link_libraries(test_bar ${Boost_LIBRARIES} my-project)

but it does not work as I expected (see bug
http://www.cmake.org/Bug/view.php?id=13244).
I realized that is not a cmake bug but my misunderstanding of cmake.

Correct me if I am wrong but I think the cmake way looks like:
test/CMakeLists.txt
add_subdirectory(foo)
add_subdirectory(bar)

test/foo/CMakeLists.txt
find_package(Boost COMPONENTS thread)
add_executable(test_foo test_foo.cpp)
add_test(test_foo test_foo)
target_link_libraries(test_foo ${Boost_LIBRARIES} my-project)

test/bar/CMakeLists.txt
find_package(Boost COMPONENTS system)
add_executable(test_bar test_bar.cpp)
add_test(test_bar test_bar)
target_link_libraries(test_bar ${Boost_LIBRARIES} my-project)

but I think this solution is a bit verbose because we need to create a
directory for each test.

So, I have 2 questions:
- how do you organize your tests within cmake? / what is the cmake way to
organize test?
- how do you handle multiple targets in the same CMakeLists.txt with
differents dependencies? / what is the cmake way to handle multiple targets
in the same CMakeLists.txt with differents dependencies?

Regards,
Damien R.
--

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