Re: [CMake] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Eric Noulard
Le mar. 11 sept. 2018 à 22:09, Michael Jackson 
a écrit :

> I add it manually each and every time. I have to tell all new developers
> to remember to add the flag otherwise they are still sitting after an hour
> waiting on our code to compile wondering why it takes so long. Then it hits
> us, "Oh, Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the
> situation but not sure how to fix it. I tried the other suggestions and
> just nothing works. This is one of those things that I poke at once a year
> and figure out that nothing has changed. Been this way since VS 2013.
> Someday it will change.
>

I don't know your constraint on using msbuild but if the "main" issue is to
automatically exploit parallel build did you try to switch to ninja instead
of msbuild?

Visual C++ Tools for CMake seems to  [begin to] support that path as well:
https://blogs.msdn.microsoft.com/vcblog/2017/05/10/cmake-support-in-visual-studio-whats-new-in-2017-15-3-update/


-- 
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:
https://cmake.org/mailman/listinfo/cmake


[CMake] SOVERSION and Mac library id in shared library made from assembly files

2018-09-11 Thread René J . V . Bertin
Hi,

I have a little project that creates a shared library from a pair of assembly 
files. I've been trying to follow examples such that the generated library

- has versioning (libFastCompression.1.dylib on Mac or libFastCompression.so.1 
on Linux)
- has the full path as its ID on Mac


I get this in the projects I used as example, but not in this particular 
project.

Am I overlooking/forgetting something, or is what I'm looking for not 
implemented/supported for libraries built exclusively from assembly files?

The project: github.com/RJVB/lzvn

Thanks!

René
-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Thompson, KT
Michael,

I agree heartily with your frustration concerning how CMake handles compiler 
flags -- especially when the FLAG strings seen in cmake-gui don't match the 
baseline flags used by the build.  I use a heavy handed, old-fashioned approach 
to solve this problem.

I ignore all of CMake's default compiler flags.  Instead of using CMake's 
defaults, I set these flags manually for every supported build environment. For 
example, I have a setflags.cmake file included from my top level CMakeLists.txt 
that contains logic that looks something like this:

if( NOT C_FLAGS_INITIALIZED )
  # only do this on the first pass through to avoid overwriting user added 
options.
  set( C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Are compiler flags already 
set?" )

  # Overwrite CMake's defaults...
  if( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set( CMAKE_C_FLAGS"-Wall -pedantic -Wunused-macros" )
set( CMAKE_C_FLAGS_DEBUG  "-g -DDEBUG")
set( CMAKE_C_FLAGS_RELEASE"-O3 -DNDEBUG" )
set( CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE}" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -gdwarf-3" )
# in a similar fashion, provide CXX_FLAGS and Fortran_FLAGS

  elseif( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set( CMAKE_C_FLAGS "/fp:precise /DWIN32 /D_WINDOWS /MP" )
...
  endif()
endif()

# Save the current compiler flags to the cache every time cmake configures the 
project.
set(CMAKE_C_FLAGS"${CMAKE_C_FLAGS}"CACHE
 STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_DEBUG  "${CMAKE_C_FLAGS_DEBUG}"  CACHE
 STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_RELEASE"${CMAKE_C_FLAGS_RELEASE}"CACHE
 STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}" CACHE
 STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE
 STRING "compiler flags" FORCE)
# and similar for CXX_FLAGS and Fortran_FLAGS...

With this logic, I have customized baseline compiler flags that show up for 
everyone and they match the strings found in CMakeCache.txt (and via 
cmake-gui).  If I modify the flags via ccmake or cmake-gui, the new options are 
saved to the cache and are used by the build.  

I manually set many more flags for my default set than I show in the example 
above and I have extra logic to check compiler version or option availability 
(e.g.: if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) -> add some gcc-8 
flags).  I also have some logic that looks for flags set in the environment and 
these options are appended to these strings before the strings are saved to the 
cache.  

There are a few downsides to this approach:
- I build on many different platforms with many different compilers, so I have 
a significant amount of cmake code to manage.
- Some flags that are set automagically set by cmake don't show up in the 
_FLAGS strings.  For example, setting CMAKE_CXX_STANDARD will add appropriate 
compiler flags like '-std=c++14' but you don't see them in cmake-gui. 

In a few cases I also use per-sourcefile, per-target, and per-directory 
properties (sometimes via generator expressions) as other have described in 
replying to your question.  In most cases, I have found that the default flags 
that are set by the top level of my build system prevent me from needing to 
customize compile flags for individual targets.

I hope this helps.

-kt

-Original Message-
From: CMake  On Behalf Of Michael Jackson
Sent: Tuesday, September 11, 2018 2:10 PM
To: cmake@cmake.org
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

I add it manually each and every time. I have to tell all new developers to 
remember to add the flag otherwise they are still sitting after an hour waiting 
on our code to compile wondering why it takes so long. Then it hits us, "Oh, 
Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the situation but 
not sure how to fix it. I tried the other suggestions and just nothing works. 
This is one of those things that I poke at once a year and figure out that 
nothing has changed. Been this way since VS 2013. Someday it will change.

--
Mike Jackson 

On 9/11/18, 1:28 PM, "CMake on behalf of Innokentiy Alaytsev" 
 wrote:

Hello!

Did you consider adding the flag manually during project configuration? I do
not know you use case, but after some thinking about the best way of
achieving multiprocess compilation under MSVS with CMake I decided, that the
simplest, most portable and flexible is to just add this flag manually. One
of the reasons for such a decision is that I do not know how the project may
be built and multiprocess compilation may cause problems under some hardware
configurations.

Best regards,
Innokentiy



--
Sent from: http://cmake.3232098.n2.nabble.com/
-- 

Powered by www.kitware.com

P

Re: [CMake] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Michael Jackson
I add it manually each and every time. I have to tell all new developers to 
remember to add the flag otherwise they are still sitting after an hour waiting 
on our code to compile wondering why it takes so long. Then it hits us, "Oh, 
Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the situation but 
not sure how to fix it. I tried the other suggestions and just nothing works. 
This is one of those things that I poke at once a year and figure out that 
nothing has changed. Been this way since VS 2013. Someday it will change.

--
Mike Jackson 

On 9/11/18, 1:28 PM, "CMake on behalf of Innokentiy Alaytsev" 
 wrote:

Hello!

Did you consider adding the flag manually during project configuration? I do
not know you use case, but after some thinking about the best way of
achieving multiprocess compilation under MSVS with CMake I decided, that the
simplest, most portable and flexible is to just add this flag manually. One
of the reasons for such a decision is that I do not know how the project may
be built and multiprocess compilation may cause problems under some hardware
configurations.

Best regards,
Innokentiy



--
Sent from: http://cmake.3232098.n2.nabble.com/
-- 

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



-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Michael Jackson
Just to be clear I _only_ need it when the generator is Visual Studio so I did 
the following:

 

if(MSVC_IDE)

  add_compile_options(/MP)

endif()

 

>From a clean build directory that did not add it to the CMAKE_CXX_FLAGS when 
>viewed in CMake-Gui.

 

--

Mike Jackson 

 

From: Marc CHEVRIER 
Date: Tuesday, September 11, 2018 at 1:28 PM
To: Michael Jackson 
Cc: CMake 
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

If you set directory property at the top level CMakeList.txt, before any target 
definition, all targets will inherit this value.

 

And, because property 'COMPILE_OPTIONS' supports generator expressions (see 
https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html), 
you can specify:

 

add_compile_options("$<$:/MP>")

 

 

Le mar. 11 sept. 2018 à 19:19, Michael Jackson  a 
écrit :

Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio is 
that it will inform the compiler to use all the cores on the system to compile. 
Much like Ninja does automatically and “make -jN” does for makefiles.

Essentially I want to automatically add the “/MP” flag anytime that I configure 
using Visual Studio (2015/2017) as the generator. I guess I could put the 
append string fairly high up in the CMake hierarchy. I am not seeing a property 
(from the first link you sent) that would allow me to do that.

 

--

Michael Jackson | Owner, President

  BlueQuartz Software

[e] mike.jack...@bluequartz.net

[w] www.bluequartz.net

 

From: Marc CHEVRIER 
Date: Tuesday, September 11, 2018 at 1:04 PM
To: Michael Jackson 
Cc: CMake 
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

The best approach is to use properties (see 
https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

 

At directory level and target level you can use property 'COMPILE_OPTIONS'.  
These properties can be updated using, respectively 'add_compile_options' and 
'target_compile_options'.

 

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have 
to use:

string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")

 

 

Le mar. 11 sept. 2018 à 17:58, Michael Jackson  a 
écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I 
would like:

 

If (MSVC)

Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. 
What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

  BlueQuartz Software

[e] mike.jack...@bluequartz.net

[w] www.bluequartz.net

-- 

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

-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Richard A. Smith

On 09/11/2018 01:03 PM, Marc CHEVRIER wrote:

The best approach is to use properties (see 
https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).


At directory level and target level you can use property 
'COMPILE_OPTIONS'.  These properties can be updated using, respectively 
'add_compile_options' and 'target_compile_options'.


If you have assembly files you may run into trouble.

See my question:  https://www.mail-archive.com/cmake@cmake.org/msg59526.html

I don't have a solution yet.



Le mar. 11 sept. 2018 à 17:58, Michael Jackson 
mailto:mike.jack...@bluequartz.net>> a écrit :


What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the
logic that I would like:

__ __

If (MSVC)

     Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

__ __

I have always heard that appending to the compile flags in this way
is “bad”. What is the best practice for doing this?

__ __

Thanks

--

Michael Jackson | Owner, President

   BlueQuartz Software

[e] mike.jack...@bluequartz.net 

[w] www.bluequartz.net 

--
Richard A. Smith
sm...@whoop.com
--

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Innokentiy Alaytsev
Hello!

Did you consider adding the flag manually during project configuration? I do
not know you use case, but after some thinking about the best way of
achieving multiprocess compilation under MSVS with CMake I decided, that the
simplest, most portable and flexible is to just add this flag manually. One
of the reasons for such a decision is that I do not know how the project may
be built and multiprocess compilation may cause problems under some hardware
configurations.

Best regards,
Innokentiy



--
Sent from: http://cmake.3232098.n2.nabble.com/
-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Marc CHEVRIER
If you set directory property at the top level CMakeList.txt, before any
target definition, all targets will inherit this value.

And, because property 'COMPILE_OPTIONS' supports generator expressions (see
https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html),
you can specify:

add_compile_options("$<$:/MP>")


Le mar. 11 sept. 2018 à 19:19, Michael Jackson 
a écrit :

> Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio
> is that it will inform the compiler to use all the cores on the system to
> compile. Much like Ninja does automatically and “make -jN” does for
> makefiles.
>
> Essentially I want to automatically add the “/MP” flag anytime that I
> configure using Visual Studio (2015/2017) as the generator. I guess I could
> put the append string fairly high up in the CMake hierarchy. I am not
> seeing a property (from the first link you sent) that would allow me to do
> that.
>
>
>
> --
>
> Michael Jackson | Owner, President
>
>   BlueQuartz Software
>
> [e] mike.jack...@bluequartz.net
>
> [w] www.bluequartz.net
>
>
>
> *From: *Marc CHEVRIER 
> *Date: *Tuesday, September 11, 2018 at 1:04 PM
> *To: *Michael Jackson 
> *Cc: *CMake 
> *Subject: *Re: [CMake] Appending to CMAKE_CXX_FLAGS
>
>
>
> The best approach is to use properties (see
> https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).
>
>
>
> At directory level and target level you can use property
> 'COMPILE_OPTIONS'.  These properties can be updated using, respectively
> 'add_compile_options' and 'target_compile_options'.
>
>
>
> Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you
> have to use:
>
> string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")
>
>
>
>
>
> Le mar. 11 sept. 2018 à 17:58, Michael Jackson <
> mike.jack...@bluequartz.net> a écrit :
>
> What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic
> that I would like:
>
>
>
> If (MSVC)
>
> Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)
>
> Endif()
>
>
>
> I have always heard that appending to the compile flags in this way is
> “bad”. What is the best practice for doing this?
>
>
>
> Thanks
>
> --
>
> Michael Jackson | Owner, President
>
>   BlueQuartz Software
>
> [e] mike.jack...@bluequartz.net
>
> [w] www.bluequartz.net
>
> --
>
> 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
>
>
-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Michael Jackson
Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio is 
that it will inform the compiler to use all the cores on the system to compile. 
Much like Ninja does automatically and “make -jN” does for makefiles.

Essentially I want to automatically add the “/MP” flag anytime that I configure 
using Visual Studio (2015/2017) as the generator. I guess I could put the 
append string fairly high up in the CMake hierarchy. I am not seeing a property 
(from the first link you sent) that would allow me to do that.

 

--

Michael Jackson | Owner, President

  BlueQuartz Software

[e] mike.jack...@bluequartz.net

[w] www.bluequartz.net

 

From: Marc CHEVRIER 
Date: Tuesday, September 11, 2018 at 1:04 PM
To: Michael Jackson 
Cc: CMake 
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

The best approach is to use properties (see 
https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

 

At directory level and target level you can use property 'COMPILE_OPTIONS'.  
These properties can be updated using, respectively 'add_compile_options' and 
'target_compile_options'.

 

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have 
to use:

string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")

 

 

Le mar. 11 sept. 2018 à 17:58, Michael Jackson  a 
écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I 
would like:

 

If (MSVC)

Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. 
What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

  BlueQuartz Software

[e] mike.jack...@bluequartz.net

[w] www.bluequartz.net

-- 

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

-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Marc CHEVRIER
The best approach is to use properties (see
https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

At directory level and target level you can use property
'COMPILE_OPTIONS'.  These properties can be updated using, respectively
'add_compile_options' and 'target_compile_options'.

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you
have to use:
string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")


Le mar. 11 sept. 2018 à 17:58, Michael Jackson 
a écrit :

> What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic
> that I would like:
>
>
>
> If (MSVC)
>
> Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)
>
> Endif()
>
>
>
> I have always heard that appending to the compile flags in this way is
> “bad”. What is the best practice for doing this?
>
>
>
> Thanks
>
> --
>
> Michael Jackson | Owner, President
>
>   BlueQuartz Software
>
> [e] mike.jack...@bluequartz.net
>
> [w] www.bluequartz.net
> --
>
> 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
>
-- 

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] Appending to CMAKE_CXX_FLAGS

2018-09-11 Thread Michael Jackson
What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I 
would like:

 

If (MSVC)

    Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. 
What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

  BlueQuartz Software

[e] mike.jack...@bluequartz.net

[w] www.bluequartz.net

-- 

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] Problems with static jpeg library

2018-09-11 Thread Eric Noulard
Le mar. 11 sept. 2018 à 16:10,  a écrit :

> Hi,
>
> thank you for your reply. I could solve the problem. The part I didn't
> knew was that static libraries also needed to be compiled with -fPIC.
> I've found a good summary of this topic at
> https://lists.debian.org/debian-devel/2016/05/msg00309.html
> I want to share it for those, who also stumble upon this problem.
>


And for project using CMake as build system one can use,
POSITION_INDEPENDENT_CODE
target property:
https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html#prop_tgt:POSITION_INDEPENDENT_CODE
or globally:
https://cmake.org/cmake/help/latest/variable/CMAKE_POSITION_INDEPENDENT_CODE.html#variable:CMAKE_POSITION_INDEPENDENT_CODE

in order to enable such flags.



>
> On 2018-09-11 13:47, Rolf Eike Beer wrote:
> > wo...@masterdevops.eu wrote:
> >> Hi,
> >>
> >> I am trying to compile the project libgd
> >> (https://github.com/libgd/libgd) with the option ENABLE_JPEG enabled.
> >>
> >> I.e. first I downloaded the source code of libjpeg-turbo from
> >> https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/, compiled
> >> it
> >
> > You need to make sure that this compile includes -fPIC in the
> > compileflags of
> > libjpeg.
> >
> >> But I get several errors like this one:
> >> > /usr/bin/ld: .../libjpeg-turbo-2.0.0/libjpeg.a(jcmainct.c.o):
> >> > relocation R_X86_64_32S against `.text' can not be used when making a
> >> > shared object; recompile with -fPIC
> >
> > As said here.
> >
> > Eike
> > --
>
> --
> German DevPos site: https://www.masterdevops.eu
> --
>
> 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
>


-- 
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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with static jpeg library

2018-09-11 Thread world

Hi,

thank you for your reply. I could solve the problem. The part I didn't 
knew was that static libraries also needed to be compiled with -fPIC. 
I've found a good summary of this topic at 
https://lists.debian.org/debian-devel/2016/05/msg00309.html

I want to share it for those, who also stumble upon this problem.


On 2018-09-11 13:47, Rolf Eike Beer wrote:

wo...@masterdevops.eu wrote:

Hi,

I am trying to compile the project libgd
(https://github.com/libgd/libgd) with the option ENABLE_JPEG enabled.

I.e. first I downloaded the source code of libjpeg-turbo from
https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/, compiled 
it


You need to make sure that this compile includes -fPIC in the 
compileflags of

libjpeg.


But I get several errors like this one:
> /usr/bin/ld: .../libjpeg-turbo-2.0.0/libjpeg.a(jcmainct.c.o):
> relocation R_X86_64_32S against `.text' can not be used when making a
> shared object; recompile with -fPIC


As said here.

Eike
--


--
German DevPos site: https://www.masterdevops.eu
--

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] Joining an OBJECT and a SHARED library

2018-09-11 Thread Robert Maynard
I believe what you are looking for in the CMake 3.12 improvements to
object libraries. In 3.12  the target_link_libraries command now
supports linking to an object library to embed the object files ( only
on direct dependencies, no propagation of .objs ) and also propagates
usage requirements like any other library.


On Wed, Sep 5, 2018 at 12:27 PM George PF  wrote:
>
> Hi,
>
> is there a way to "join" an the OBJECT library with a SHARED library it 
> creates?
>
> The abclib and its component abc_tmp, all .c file have #include "foo.h":
>
> add_library(abc_tmp OBJECT z1. z2.c)
> # generate...
> add_library(abclib SHARED $ generated.c)
>
> Then adding the library foo, which adds the include path to "foo.h" - but 
> this only
> works for 'generated.c', the include path for z1/z1 is not extended:
>
> target_link_libraries(abclib PUBLIC foo)
>
> Repeating the same for 'abc_tmp' is really cumbersome, I want to this to 
> apply to everything
> which goes into creating the abclib, directly or indirectly, is that possible?
>
>
> Regards
>
> GPF
> --
>
> 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
-- 

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] Problems with static jpeg library

2018-09-11 Thread Rolf Eike Beer
wo...@masterdevops.eu wrote:
> Hi,
> 
> I am trying to compile the project libgd
> (https://github.com/libgd/libgd) with the option ENABLE_JPEG enabled.
> 
> I.e. first I downloaded the source code of libjpeg-turbo from
> https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/, compiled it

You need to make sure that this compile includes -fPIC in the compileflags of 
libjpeg.

> But I get several errors like this one:
> > /usr/bin/ld: .../libjpeg-turbo-2.0.0/libjpeg.a(jcmainct.c.o):
> > relocation R_X86_64_32S against `.text' can not be used when making a
> > shared object; recompile with -fPIC

As said here.

Eike
-- 

signature.asc
Description: This is a digitally signed message part.
-- 

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] Problems with static jpeg library

2018-09-11 Thread world

Hi,

I am trying to compile the project libgd 
(https://github.com/libgd/libgd) with the option ENABLE_JPEG enabled.


I.e. first I downloaded the source code of libjpeg-turbo from 
https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/, compiled it 
and afterwards I started to compile libgd with this command:



cmake -G "Unix Makefiles" \

-DENABLE_JPEG=ON \
-DJPEG_INCLUDE_DIR="../${JPEG_DIR}" \
-DJPEG_LIBRARY="../${JPEG_DIR}/libjpeg.a" \
.

You can check the CMakeLists.txt in that project 
(https://github.com/libgd/libgd/blob/master/CMakeLists.txt)


As you can see, I want to compile libgd with a static libjpeg library. 
But I get several errors like this one:


/usr/bin/ld: .../libjpeg-turbo-2.0.0/libjpeg.a(jcmainct.c.o): 
relocation R_X86_64_32S against `.text' can not be used when making a 
shared object; recompile with -fPIC


When I use the shared library version of libjpeg, i.e. I try to compile 
libgd with the shared version of libjpeg, i.e.



cmake -G "Unix Makefiles" \

-DENABLE_JPEG=ON \
-DJPEG_INCLUDE_DIR="../${JPEG_DIR}" \
-DJPEG_LIBRARY="../${JPEG_DIR}/libjpeg.so" \
.

then there is no error.

Is this a problem of CMake or a problem of the CMakeLists.txt of the 
libgd project?

--

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