Re: [CMake] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-14 Thread Glenn Coombs
In my opinion this is a deficiency in how cmake currently works with object
libraries.  If one of the source files in an object library depends on a
third library then it should be possible to specify that in the link
interface of either the object library or the source file.  It is wrong to
have to specify the dependency multiple times for every library or
executable that uses the object library.  It is a property of the object
library, not the users of the object library.

I believe there is already a enhancement request open for something like
this.

--
Glenn



On 13 August 2014 15:44, marco restelli  wrote:

> 2014-08-13 16:16 GMT+0200, Mark Abraham :
> > On Wed, Aug 13, 2014 at 7:12 AM, marco restelli 
> > wrote:
> >
> >> 2014-08-13 15:53 GMT+0200, Mark Abraham :
> >> > On Wed, Aug 13, 2014 at 3:18 AM, marco restelli 
> >> > wrote:
> >> >
> >> >> Hi Petr,
> >> >>thanks, very informative!
> >> >>
> >> >> 2014-08-13 9:20 GMT+0200, Petr Kmoch :
> >> >> > Hi Marco.
> >> >> >
> >> >> > Sane compilers allow later command-line options to override earlier
> >> >> > ones,
> >> >> > so what you're doing should be fine. Unfortunately, I know some
> >> Fortran
> >> >> > compilers are not sane in this regard.
> >> >>
> >> >> Here, I would really like to reduce as much as possible the flags
> >> >> regardless of the chosen compiler, so "undoing" the chosen flags
> >> >> seems to me cumbersome and compiler dependent, compared to resetting
> >> >> them altogether. I like the idea of OBJECT libraries better (it also
> >> >> solves other problems I have, I did not know about it!).
> >> >>
> >> >> > If you really need to solve this by explicitly modifying the global
> >> >> > list
> >> >> > for a particular file, the only thing I can think of is move those
> >> >> > files
> >> >> to
> >> >> > a separate CMakeList and turn them into an object library:
> >> >>
> >> >> This almost works, I have a problem specifying liking dependencies
> for
> >> >> the OBJECT libraries. With a normal library, I can use
> >> >>
> >> >> TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on}
> >> >> )
> >> >>
> >> >> but if my_library is OBJECT I see the error
> >> >>
> >> >>   Object library target "my_library" may not link to anything.
> >> >>
> >> >
> >> > See http://www.cmake.org/cmake/help/v3.0/command/add_library.html for
> >> the
> >> > correct way to do things with object libraries - for this purpose,
> they
> >> are
> >> > closer to source files than libraries, which makes sense given that
> >> there's
> >> > not actually a library written to disk anywhere.
> >>
> >> Mark, thanks, but here I don't find anything that answers my question,
> >> namely specifying that my OBJECT library (i.e. the files included in
> >> it) require other libraries for linking.
> >
> >
> > The object library is never linked, so the issue of linking with it or to
> > it does not arise. The targets that use the object library have
> transitive
> > linking dependencies, just like you had if the source files in the object
> > library had been directly specified as part of those targets.
>
> OK, let me see if I understad it. Using the example in
>
> http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library
>
> let us say I have
>
>
> # A/CMakeLists.txt
> add_library(A OBJECT ${A_srcs})
>
> # B/CMakeLists.txt
> add_library(B OBJECT ${B_srcs})
>
> # CMakeLists.txt
> add_subdirectory(A)
> add_subdirectory(B)
> add_library(big ${other_srcs} $ $)
>
>
> and I know that whenever I link the files listed in ${A_srcs}, i.e.
> whenever I likd the OBJECT library A, I also need to link
> libsomeotherlibrary.a . Then in the main CMakeLists.txt I add
>
> TARGET_LINK_LIBRARIES( big someotherlibrary )
>
> right?
>
>
> Moreover, there is no way to specify someotherlibrary in
> A/CMakeLists.txt, it has to be done where I define the target big,
> namely in the main CMakeLists.txt. Is this correct?
>
>
> Thanks,
>Marco
> --
>
> 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/cma

Re: [CMake] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread marco restelli
2014-08-13 16:16 GMT+0200, Mark Abraham :
> On Wed, Aug 13, 2014 at 7:12 AM, marco restelli 
> wrote:
>
>> 2014-08-13 15:53 GMT+0200, Mark Abraham :
>> > On Wed, Aug 13, 2014 at 3:18 AM, marco restelli 
>> > wrote:
>> >
>> >> Hi Petr,
>> >>thanks, very informative!
>> >>
>> >> 2014-08-13 9:20 GMT+0200, Petr Kmoch :
>> >> > Hi Marco.
>> >> >
>> >> > Sane compilers allow later command-line options to override earlier
>> >> > ones,
>> >> > so what you're doing should be fine. Unfortunately, I know some
>> Fortran
>> >> > compilers are not sane in this regard.
>> >>
>> >> Here, I would really like to reduce as much as possible the flags
>> >> regardless of the chosen compiler, so "undoing" the chosen flags
>> >> seems to me cumbersome and compiler dependent, compared to resetting
>> >> them altogether. I like the idea of OBJECT libraries better (it also
>> >> solves other problems I have, I did not know about it!).
>> >>
>> >> > If you really need to solve this by explicitly modifying the global
>> >> > list
>> >> > for a particular file, the only thing I can think of is move those
>> >> > files
>> >> to
>> >> > a separate CMakeList and turn them into an object library:
>> >>
>> >> This almost works, I have a problem specifying liking dependencies for
>> >> the OBJECT libraries. With a normal library, I can use
>> >>
>> >> TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on}
>> >> )
>> >>
>> >> but if my_library is OBJECT I see the error
>> >>
>> >>   Object library target "my_library" may not link to anything.
>> >>
>> >
>> > See http://www.cmake.org/cmake/help/v3.0/command/add_library.html for
>> the
>> > correct way to do things with object libraries - for this purpose, they
>> are
>> > closer to source files than libraries, which makes sense given that
>> there's
>> > not actually a library written to disk anywhere.
>>
>> Mark, thanks, but here I don't find anything that answers my question,
>> namely specifying that my OBJECT library (i.e. the files included in
>> it) require other libraries for linking.
>
>
> The object library is never linked, so the issue of linking with it or to
> it does not arise. The targets that use the object library have transitive
> linking dependencies, just like you had if the source files in the object
> library had been directly specified as part of those targets.

OK, let me see if I understad it. Using the example in

http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library

let us say I have


# A/CMakeLists.txt
add_library(A OBJECT ${A_srcs})

# B/CMakeLists.txt
add_library(B OBJECT ${B_srcs})

# CMakeLists.txt
add_subdirectory(A)
add_subdirectory(B)
add_library(big ${other_srcs} $ $)


and I know that whenever I link the files listed in ${A_srcs}, i.e.
whenever I likd the OBJECT library A, I also need to link
libsomeotherlibrary.a . Then in the main CMakeLists.txt I add

TARGET_LINK_LIBRARIES( big someotherlibrary )

right?


Moreover, there is no way to specify someotherlibrary in
A/CMakeLists.txt, it has to be done where I define the target big,
namely in the main CMakeLists.txt. Is this correct?


Thanks,
   Marco
-- 

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] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread Mark Abraham
On Wed, Aug 13, 2014 at 7:12 AM, marco restelli  wrote:

> 2014-08-13 15:53 GMT+0200, Mark Abraham :
> > On Wed, Aug 13, 2014 at 3:18 AM, marco restelli 
> > wrote:
> >
> >> Hi Petr,
> >>thanks, very informative!
> >>
> >> 2014-08-13 9:20 GMT+0200, Petr Kmoch :
> >> > Hi Marco.
> >> >
> >> > Sane compilers allow later command-line options to override earlier
> >> > ones,
> >> > so what you're doing should be fine. Unfortunately, I know some
> Fortran
> >> > compilers are not sane in this regard.
> >>
> >> Here, I would really like to reduce as much as possible the flags
> >> regardless of the chosen compiler, so "undoing" the chosen flags
> >> seems to me cumbersome and compiler dependent, compared to resetting
> >> them altogether. I like the idea of OBJECT libraries better (it also
> >> solves other problems I have, I did not know about it!).
> >>
> >> > If you really need to solve this by explicitly modifying the global
> >> > list
> >> > for a particular file, the only thing I can think of is move those
> >> > files
> >> to
> >> > a separate CMakeList and turn them into an object library:
> >>
> >> This almost works, I have a problem specifying liking dependencies for
> >> the OBJECT libraries. With a normal library, I can use
> >>
> >> TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on} )
> >>
> >> but if my_library is OBJECT I see the error
> >>
> >>   Object library target "my_library" may not link to anything.
> >>
> >
> > See http://www.cmake.org/cmake/help/v3.0/command/add_library.html for
> the
> > correct way to do things with object libraries - for this purpose, they
> are
> > closer to source files than libraries, which makes sense given that
> there's
> > not actually a library written to disk anywhere.
>
> Mark, thanks, but here I don't find anything that answers my question,
> namely specifying that my OBJECT library (i.e. the files included in
> it) require other libraries for linking.


The object library is never linked, so the issue of linking with it or to
it does not arise. The targets that use the object library have transitive
linking dependencies, just like you had if the source files in the object
library had been directly specified as part of those targets.

Mark


> Marco
>
-- 

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] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread marco restelli
2014-08-13 15:53 GMT+0200, Mark Abraham :
> On Wed, Aug 13, 2014 at 3:18 AM, marco restelli 
> wrote:
>
>> Hi Petr,
>>thanks, very informative!
>>
>> 2014-08-13 9:20 GMT+0200, Petr Kmoch :
>> > Hi Marco.
>> >
>> > Sane compilers allow later command-line options to override earlier
>> > ones,
>> > so what you're doing should be fine. Unfortunately, I know some Fortran
>> > compilers are not sane in this regard.
>>
>> Here, I would really like to reduce as much as possible the flags
>> regardless of the chosen compiler, so "undoing" the chosen flags
>> seems to me cumbersome and compiler dependent, compared to resetting
>> them altogether. I like the idea of OBJECT libraries better (it also
>> solves other problems I have, I did not know about it!).
>>
>> > If you really need to solve this by explicitly modifying the global
>> > list
>> > for a particular file, the only thing I can think of is move those
>> > files
>> to
>> > a separate CMakeList and turn them into an object library:
>>
>> This almost works, I have a problem specifying liking dependencies for
>> the OBJECT libraries. With a normal library, I can use
>>
>> TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on} )
>>
>> but if my_library is OBJECT I see the error
>>
>>   Object library target "my_library" may not link to anything.
>>
>
> See http://www.cmake.org/cmake/help/v3.0/command/add_library.html for the
> correct way to do things with object libraries - for this purpose, they are
> closer to source files than libraries, which makes sense given that there's
> not actually a library written to disk anywhere.

Mark, thanks, but here I don't find anything that answers my question,
namely specifying that my OBJECT library (i.e. the files included in
it) require other libraries for linking.

Marco
-- 

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] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread Mark Abraham
On Wed, Aug 13, 2014 at 3:18 AM, marco restelli  wrote:

> Hi Petr,
>thanks, very informative!
>
> 2014-08-13 9:20 GMT+0200, Petr Kmoch :
> > Hi Marco.
> >
> > Sane compilers allow later command-line options to override earlier ones,
> > so what you're doing should be fine. Unfortunately, I know some Fortran
> > compilers are not sane in this regard.
>
> Here, I would really like to reduce as much as possible the flags
> regardless of the chosen compiler, so "undoing" the chosen flags
> seems to me cumbersome and compiler dependent, compared to resetting
> them altogether. I like the idea of OBJECT libraries better (it also
> solves other problems I have, I did not know about it!).
>
> > If you really need to solve this by explicitly modifying the global list
> > for a particular file, the only thing I can think of is move those files
> to
> > a separate CMakeList and turn them into an object library:
>
> This almost works, I have a problem specifying liking dependencies for
> the OBJECT libraries. With a normal library, I can use
>
> TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on} )
>
> but if my_library is OBJECT I see the error
>
>   Object library target "my_library" may not link to anything.
>

See http://www.cmake.org/cmake/help/v3.0/command/add_library.html for the
correct way to do things with object libraries - for this purpose, they are
closer to source files than libraries, which makes sense given that there's
not actually a library written to disk anywhere.

Mark


> One option would be adding the TARGET_LINK_LIBRARIES to the STATIC
> library where the TARGET_OBJECTS are used, but this seems to
> contradict the modularity idea of the OBJECT libraries. Is there a
> better solution?
>
> Marco
> --
>
> 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] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread marco restelli
Hi Petr,
   thanks, very informative!

2014-08-13 9:20 GMT+0200, Petr Kmoch :
> Hi Marco.
>
> Sane compilers allow later command-line options to override earlier ones,
> so what you're doing should be fine. Unfortunately, I know some Fortran
> compilers are not sane in this regard.

Here, I would really like to reduce as much as possible the flags
regardless of the chosen compiler, so "undoing" the chosen flags
seems to me cumbersome and compiler dependent, compared to resetting
them altogether. I like the idea of OBJECT libraries better (it also
solves other problems I have, I did not know about it!).

> If you really need to solve this by explicitly modifying the global list
> for a particular file, the only thing I can think of is move those files to
> a separate CMakeList and turn them into an object library:

This almost works, I have a problem specifying liking dependencies for
the OBJECT libraries. With a normal library, I can use

TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on} )

but if my_library is OBJECT I see the error

  Object library target "my_library" may not link to anything.

One option would be adding the TARGET_LINK_LIBRARIES to the STATIC
library where the TARGET_OBJECTS are used, but this seems to
contradict the modularity idea of the OBJECT libraries. Is there a
better solution?

Marco
-- 

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] Resetting CMAKE_Fortran_FLAGS for a specific file

2014-08-13 Thread Petr Kmoch
Hi Marco.

Sane compilers allow later command-line options to override earlier ones,
so what you're doing should be fine. Unfortunately, I know some Fortran
compilers are not sane in this regard.

If you really need to solve this by explicitly modifying the global list
for a particular file, the only thing I can think of is move those files to
a separate CMakeList and turn them into an object library:

# In normal CMakeList:

add_subdirectory(special_file_dir)

add_executable(YourNormalTarget normal_file1.f90 normal_file2.f90
$)


# In special_file_dir/CMakeLists.txt:

set(CMAKE_Fortran_FLAGS "-only -flags -you -want")

add_library(special_files OBJECT special_fil1.f90 special_file2.f90)


I haven't tested it, but it should work.

Petr


On Tue, Aug 5, 2014 at 4:29 PM, marco restelli  wrote:

> Hi,
>I would like to reset CMAKE_Fortran_FLAGS for one specific file in
> a project. I have tried
>
> SET_SOURCE_FILES_PROPERTIES(my_file.f90 PROPERTIES COMPILE_FLAGS "-O0 -g")
>
> but it appends the new flags keeping the old ones. How can reset these
> flags? Specifically, I have some files for which I need to avoid any
> error checking and any optimization, independently from the selected
> compiler.
>
> Thanks, regards,
>Marco
> --
>
> 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