Re: [CMake] Release flags on one target in debug build type

2017-05-05 Thread Dan Liew
On 5 May 2017 at 19:45, Konstantin Tokarev  wrote:
> Hello,
>
> Is there any clear way to build specific target in "Debug" mode with flags 
> that it would have in "Release"?
>
> In particular, build this specific target without effect of 
> CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG, while preserving flags added 
> by target_compile_options


Something like this would sort of do it.

```
target_compile_options(your_target
  PRIVATE
  $<$:$<$:${CMAKE_CXX_FLAGS_RELEASE}>>
  $<$:$<$:${CMAKE_C_FLAGS_RELEASE}>>
```

The problem you have though is that `your_target` in debug mode will
already debug build flags (e.g. `-O0 g`). So you may get conflicting
compiler options.

Another way of doing this is to build your target as an external
project where you set the build mode of the external project to be
release.
-- 

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] Release flags on one target in debug build type

2017-05-05 Thread Konstantin Tokarev


05.05.2017, 23:22, "Michael Ellery" :
>>  On May 5, 2017, at 11:45 AM, Konstantin Tokarev  wrote:
>>
>>  Hello,
>>
>>  Is there any clear way to build specific target in "Debug" mode with flags 
>> that it would have in "Release"?
>>
>>  In particular, build this specific target without effect of 
>> CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG, while preserving flags added 
>> by target_compile_options
>>
>>  --
>>  Regards,
>>  Konstantin
>>  --
>>
>>  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
>
> Does RelWithDebInfo do what you want? I have in the past taken one of the 
> “alternative targets” (RelWithDebInfo or MinSIzeRel) and adjusted the flags 
> for that target until it suited my specific needs, but I don’t necessarily 
> claim that is the right way to go in all cases. Also be aware that the 
> default optimization level can differ slightly with each of these build 
> types. In the end, it’s probably best to survey the current settings for each 
> build type and see if one is close to what you want.

I need to modify build of one target, not to change global build type of the 
project 

>
> -Mike

-- 
Regards,
Konstantin
-- 

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] Release flags on one target in debug build type

2017-05-05 Thread Michael Ellery

> On May 5, 2017, at 11:45 AM, Konstantin Tokarev  wrote:
> 
> Hello,
> 
> Is there any clear way to build specific target in "Debug" mode with flags 
> that it would have in "Release"?
> 
> In particular, build this specific target without effect of 
> CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG, while preserving flags added 
> by target_compile_options
> 
> -- 
> Regards,
> Konstantin
> -- 
> 
> 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


Does RelWithDebInfo do what you want? I have in the past taken one of the 
“alternative targets” (RelWithDebInfo or MinSIzeRel) and adjusted the flags for 
that target until it suited my specific needs, but I don’t necessarily claim 
that is the right way to go in all cases. Also be aware that the default 
optimization level can differ slightly with each of these build types. In the 
end, it’s probably best to survey the current settings for each build type and 
see if one is close to what you want.

-Mike

-- 

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] Release flags on one target in debug build type

2017-05-05 Thread Konstantin Tokarev
Hello,

Is there any clear way to build specific target in "Debug" mode with flags that 
it would have in "Release"?

In particular, build this specific target without effect of 
CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG, while preserving flags added by 
target_compile_options

-- 
Regards,
Konstantin
-- 

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] setting environment variable for ctest

2017-05-05 Thread CHEVRIER, Marc
Use the ENVIRONMENT property of your tests (see 
https://cmake.org/cmake/help/v3.7/prop_test/ENVIRONMENT.html).

On 05/05/2017, 16:29, "CMake on behalf of Juan E. Sanchez" 
 wrote:

Hello,

It appears that when I invoke ctest through cmake, the environment 
variables I export from my bash shell are being ignored:
DYLD_INSERT_LIBRARIES
PATH

Is there a way to tell cmake to pass the user environment all the way 
down to the environment for my tested application.

This is on Mac OS X (El Capitan) with the latest cmake binary download 
3.8.1.

Regards,

Juan

-- 

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] setting environment variable for ctest

2017-05-05 Thread Juan E. Sanchez
It this possible to set for all tests as one line?  This would require 
changing dozens of tests.


Regards,

Juan

On 5/5/17 9:31 AM, CHEVRIER, Marc wrote:

Use the ENVIRONMENT property of your tests (see 
https://cmake.org/cmake/help/v3.7/prop_test/ENVIRONMENT.html).

On 05/05/2017, 16:29, "CMake on behalf of Juan E. Sanchez" 
 wrote:

Hello,

It appears that when I invoke ctest through cmake, the environment
variables I export from my bash shell are being ignored:
DYLD_INSERT_LIBRARIES
PATH

Is there a way to tell cmake to pass the user environment all the way
down to the environment for my tested application.

This is on Mac OS X (El Capitan) with the latest cmake binary download
3.8.1.

Regards,

Juan

--

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


[CMake] setting environment variable for ctest

2017-05-05 Thread Juan E. Sanchez

Hello,

It appears that when I invoke ctest through cmake, the environment 
variables I export from my bash shell are being ignored:

DYLD_INSERT_LIBRARIES
PATH

Is there a way to tell cmake to pass the user environment all the way 
down to the environment for my tested application.


This is on Mac OS X (El Capitan) with the latest cmake binary download 
3.8.1.


Regards,

Juan

--

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] Does JOB_POOL_[COMPILE|LINK] work with custom_target?

2017-05-05 Thread Eric Noulard
Hi all,

We have a bunch of custom_target and a subset of them should be run in
sequence.
So we tried to define:

set_property(GLOBAL PROPERTY JOB_POOLS exclusive=1)

and then:

set_property(TARGET my_custom_target PROPERTY JOB_POOL_COMPILE exclusive)
set_property(TARGET my_custom_target PROPERTY JOB_POOL_LINK exclusive)


This does not seem to reach build.ninja ?

The new pool is defined but the concerned custom targets are never assigned
to the pool?

May custom target be assigned to a ninja pool?
If so how can we do that?
--
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

Re: [CMake] Circular dependencies with Ninja, not with Unix Makefiles

2017-05-05 Thread Ignacio Fernández Galván via CMake
Well, in my real case this happens even with out-of-source builds, which 
also occurs in the test case if I change:


set (OUT ${CMAKE_BINARY_DIR}/ext)

in ext/CMakeLists.txt.

Sure, I can avoid it by renaming the file or target, but I thought this 
is something that could be avoided by either (a) generating unique ninja 
target names when possible, or (b) warning at the cmake stage that 
target names are duplicated.


From my point of view as a CMake user, I see no reason why the 
combination of add_custom_command and add_custom_target should have a 
conflict.


On 05/05/17 14:22, Robert Maynard wrote:

Hi,

This is caused by doing an in source build and thereby causing the
issue. The custom command is outputting a file called 'foo', which is
also the chosen name of a target in the ninja file. All of this results
in ninja conflating the two and causing a circular dependency.

Your options are to not to in source builds, or to choose a different
name for your custom target.

On Thu, May 4, 2017 at 3:55 AM, Ignacio Fernández Galván via CMake
mailto:cmake@cmake.org>> wrote:

Hello,

I have a project where circular dependencies are generated when I
use the Ninja generator, but not the default Unix Makefiles. I could
create a minimal test like this:

$ cat CMakeLists.txt
add_subdirectory (ext ${PROJECT_BINARY_DIR}/ext)

$ cat ext/CMakeLists.txt
set (OUT ${CMAKE_CURRENT_LIST_DIR})

add_custom_command (OUTPUT ${OUT}/foo
COMMAND touch ${OUT}/foo
)

add_custom_target (foo ALL
DEPENDS ${OUT}/foo
)

add_custom_command (TARGET foo
POST_BUILD
COMMAND cp ${OUT}/foo ${CMAKE_BINARY_DIR}/foo
)

$ touch ext/bar

$ cmake -G Ninja .
[...]

$ ninja
ninja: warning: multiple rules generate ext/foo. builds involving
this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: error: dependency cycle: ext/foo -> ext/CMakeFiles/foo.util
-> ext/CMakeFiles/foo -> ext/foo

I used a freshly compiled CMake 3.8 and the latest binary ninja from
https://github.com/Kitware/ninja/releases
.

Ignacio
--

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] avoiding finding system libraries (motivation is superbuilds)

2017-05-05 Thread Robert Maynard
Have you tried using CMAKE_PREFIX_PATH instead of CMAKE_INSTALL_PREFIX?

On Thu, May 4, 2017 at 5:13 PM, Kris Thielemans  wrote:

> Hi
>
>
>
> Short question: if we have a library/include files installed both in the
> usual system locations and outside, how do we force CMake to find the
> latter? (without modifying the CMake files of the project).
>
>
>
> Motivation:
>
> We’re trying to make a SuperBuild that builds/downloads a specific version
> of various packages (such as Boost and GTest). Our motivation is to have
> complete control of the version. We don’t want to install this in standard
> locations to avoid clashes, root permissions etc.  So let’s say we install
> our versions in ~/our_stuff/lib, ~/our_stuff/include etc
>
>
>
> It seems very hard (and sometimes impossible) however to let future
> find_packages find our own versions as opposed to the system ones. From
> https://cmake.org/cmake/help/latest/command/find_library.html I thought
> that doing something like this would work
>
>
>
> cmake ../ -DCMAKE_INSTALL_PREFIX=~/our_stuff
>
>
>
> but the system version of boost etc are still found first (it does work if
> there is no system version of the library). In the case of Boost, even
>
>
>
> cmake ../ -DCMAKE_INSTALL_PREFIX=~/our_stuff -DBOOST_ROOT=~/our_stuff
>
>
>
> doesn’t help (tested on Linux). I have to set BOOST_INCLUDEDIR for
> instance. As every Find*.cmake has its own conventions of specifying
> cmake/environment variables, and some don’t at all, this just gets
> unfeasible.
>
>
>
> I know about NO_DEFAULT_PATH, NO_CMAKE_SYSTEM_PATH etc options for
> find_package, but this would need modification of CMake files in the
> dependent packages which is quite undesirable for us.
>
>
>
> Any suggestions?
>
>
>
> Thanks
>
> Kris
>
>
>
> --
>
> 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] Circular dependencies with Ninja, not with Unix Makefiles

2017-05-05 Thread Robert Maynard
Hi,

This is caused by doing an in source build and thereby causing the issue.
The custom command is outputting a file called 'foo', which is also the
chosen name of a target in the ninja file. All of this results in ninja
conflating the two and causing a circular dependency.

Your options are to not to in source builds, or to choose a different name
for your custom target.

On Thu, May 4, 2017 at 3:55 AM, Ignacio Fernández Galván via CMake <
cmake@cmake.org> wrote:

> Hello,
>
> I have a project where circular dependencies are generated when I use the
> Ninja generator, but not the default Unix Makefiles. I could create a
> minimal test like this:
>
> $ cat CMakeLists.txt
> add_subdirectory (ext ${PROJECT_BINARY_DIR}/ext)
>
> $ cat ext/CMakeLists.txt
> set (OUT ${CMAKE_CURRENT_LIST_DIR})
>
> add_custom_command (OUTPUT ${OUT}/foo
> COMMAND touch ${OUT}/foo
> )
>
> add_custom_target (foo ALL
> DEPENDS ${OUT}/foo
> )
>
> add_custom_command (TARGET foo
> POST_BUILD
> COMMAND cp ${OUT}/foo ${CMAKE_BINARY_DIR}/foo
> )
>
> $ touch ext/bar
>
> $ cmake -G Ninja .
> [...]
>
> $ ninja
> ninja: warning: multiple rules generate ext/foo. builds involving this
> target will not be correct; continuing anyway [-w dupbuild=warn]
> ninja: error: dependency cycle: ext/foo -> ext/CMakeFiles/foo.util ->
> ext/CMakeFiles/foo -> ext/foo
>
> I used a freshly compiled CMake 3.8 and the latest binary ninja from
> https://github.com/Kitware/ninja/releases.
>
> Ignacio
> --
>
> 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/opensou
> rce/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