Re: [CMake] Fwd: set_target_properties and language specific COMPILE_FLAGS
The solution is to add the POSITION_INDENPENDENT_CODE target property to the C and Fortran convenience library targets. Thanks again for the help, nick On Mon, Aug 4, 2014 at 3:35 PM, Nicolas Bock wrote: > Hi Chuck, > > I am building both static and shared libraries using the object files. > After splitting the Fortran and C source as you suggest, I get the > following linker error: > > /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: > CMakeFiles/spammpack-serial-C.dir/spamm_get_time.c.o: relocation > R_X86_64_32 against `.rodata' can not be used when making a shared > object; recompile with -fPIC > > Unfortunately I can't reproduce this error with a smaller test. Should > I pass some additional compiler flags into the OBJECT convenience > library, such as -fPIC as is suggested by the linker? How portable > would that be? > > Thanks already, > > nick > > On Fri, Aug 1, 2014 at 12:37 PM, Chuck Atkins > wrote: >> Hi Nick, >> >> You could split your target in to two object libraries that combine into a >> singe "real" library: >> >> add_library(foo_f OBJECT ${FOO_F_SOURCES}) >> # set necessary compile flags specific to the Fortran components >> # on the foo_f target >> >> add_library(foo_c OBJECT ${FOO_C_SOURCES}) >> # set necessary compile flags specific to the C components >> # on the foo_c target >> >> # Combine into a "real" library >> add_library(foo $ $) >> >> See http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library >> >> - Chuck >> >> >> On Fri, Aug 1, 2014 at 12:54 PM, Nicolas Bock wrote: >>> >>> Hi, >>> >>> I am building a library containing Fortran and C sources. I would like >>> to add language specific compile flags without affecting the global >>> compile flags: >>> >>> set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS >>> "-openmp" ) >>> >>> However, it seems there is only COMPILE_FLAGS which presumably affects >>> both languages. >>> >>> Thanks already, >>> >>> nick >>> -- >>> >>> 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] Fwd: set_target_properties and language specific COMPILE_FLAGS
Hi Chuck, I am building both static and shared libraries using the object files. After splitting the Fortran and C source as you suggest, I get the following linker error: /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/spammpack-serial-C.dir/spamm_get_time.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC Unfortunately I can't reproduce this error with a smaller test. Should I pass some additional compiler flags into the OBJECT convenience library, such as -fPIC as is suggested by the linker? How portable would that be? Thanks already, nick On Fri, Aug 1, 2014 at 12:37 PM, Chuck Atkins wrote: > Hi Nick, > > You could split your target in to two object libraries that combine into a > singe "real" library: > > add_library(foo_f OBJECT ${FOO_F_SOURCES}) > # set necessary compile flags specific to the Fortran components > # on the foo_f target > > add_library(foo_c OBJECT ${FOO_C_SOURCES}) > # set necessary compile flags specific to the C components > # on the foo_c target > > # Combine into a "real" library > add_library(foo $ $) > > See http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library > > - Chuck > > > On Fri, Aug 1, 2014 at 12:54 PM, Nicolas Bock wrote: >> >> Hi, >> >> I am building a library containing Fortran and C sources. I would like >> to add language specific compile flags without affecting the global >> compile flags: >> >> set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS >> "-openmp" ) >> >> However, it seems there is only COMPILE_FLAGS which presumably affects >> both languages. >> >> Thanks already, >> >> nick >> -- >> >> 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] Fwd: set_target_properties and language specific COMPILE_FLAGS
Hi Chuck, seems a bit hackish, but works for me :) Thanks for the trick! nick On Fri, Aug 1, 2014 at 12:37 PM, Chuck Atkins wrote: > Hi Nick, > > You could split your target in to two object libraries that combine into a > singe "real" library: > > add_library(foo_f OBJECT ${FOO_F_SOURCES}) > # set necessary compile flags specific to the Fortran components > # on the foo_f target > > add_library(foo_c OBJECT ${FOO_C_SOURCES}) > # set necessary compile flags specific to the C components > # on the foo_c target > > # Combine into a "real" library > add_library(foo $ $) > > See http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library > > - Chuck > > > On Fri, Aug 1, 2014 at 12:54 PM, Nicolas Bock wrote: >> >> Hi, >> >> I am building a library containing Fortran and C sources. I would like >> to add language specific compile flags without affecting the global >> compile flags: >> >> set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS >> "-openmp" ) >> >> However, it seems there is only COMPILE_FLAGS which presumably affects >> both languages. >> >> Thanks already, >> >> nick >> -- >> >> 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] Fwd: set_target_properties and language specific COMPILE_FLAGS
Hi Nick, You could split your target in to two object libraries that combine into a singe "real" library: add_library(foo_f OBJECT ${FOO_F_SOURCES}) # set necessary compile flags specific to the Fortran components # on the foo_f target add_library(foo_c OBJECT ${FOO_C_SOURCES}) # set necessary compile flags specific to the C components # on the foo_c target # Combine into a "real" library add_library(foo $ $) See http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library - Chuck On Fri, Aug 1, 2014 at 12:54 PM, Nicolas Bock wrote: > Hi, > > I am building a library containing Fortran and C sources. I would like > to add language specific compile flags without affecting the global > compile flags: > > set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS > "-openmp" ) > > However, it seems there is only COMPILE_FLAGS which presumably affects > both languages. > > Thanks already, > > nick > -- > > 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] Fwd: set_target_properties and language specific COMPILE_FLAGS
Hi, I am building a library containing Fortran and C sources. I would like to add language specific compile flags without affecting the global compile flags: set_target_properties( foo PROPERTIES C_FLAGS "-fopenmp" Fortran_FLAGS "-openmp" ) However, it seems there is only COMPILE_FLAGS which presumably affects both languages. Thanks already, nick -- 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