[CMake] compiler independent compiler flags

2016-02-05 Thread 🐋 Jan Hegewald
Dear all,
do you know a best practice on how to specify compiler flags without knowing in 
advance which compiler will be used?
Its about Fortran projects, where I e.g. want to explicitly enable the 
preprocessor, or make all default real values 8 byte wide. This could be done 
as such:
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
  set(CMAKE_Fortran_FLAGS "-fpp -r8")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
  set(CMAKE_Fortran_FLAGS "-cpp -fdefault-real-8")
endif()

Cmake has the cmake-compile-features and I though maybe some similar mechanism 
exists for above mentioned compiler switches. So I could say
target_compile_features(mylib PRIVATE f_preprocessor f_real_8)

Thanks for sharing your advise,
Jan


-- 

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] cmake 3.5.0-rc1 Error copying Fortran module

2016-02-05 Thread Brad King
On 02/04/2016 04:00 PM, Thompson, KT wrote:
> If I run ‘make VERBOSE=1’ with CMake-3.4.3, I see the following command:
> 
> cmake -E cmake_copy_f90_mod src/dir1/dir2/myf90file 
> src/dir1/dir2/CMakeFiles/Lib_FC_f90sub.dir/myf90file.mod.stamp Intel
> 
> but with CMake-3.5.0-rc1, I have this command (notice that no path is
> provided for the filename (argument 3)):
> 
> cmake -E cmake_copy_f90_mod myf90file 
> src/dir1/dir2/CMakeFiles/Lib_FC_f90sub.dir/myf90file.mod.stamp Intel

Thanks.  Here is a fix and a new test case:

 Fix dependency scanning configuration in subdirectories
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5eb21b6

I've queued this for merge to 'release' for inclusion in 3.5.0-rc2.

-Brad

-- 

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] cmake 3.5.0-rc1 Error copying Fortran module

2016-02-05 Thread Thompson, KT
Brad,

I want to confirm that your patch below fixed the issue that I reported.

Thank you!

-kt

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Friday, February 05, 2016 7:32 AM
To: Thompson, KT 
Cc: cmake@cmake.org; Stephen Kelly 
Subject: Re: [CMake] cmake 3.5.0-rc1 Error copying Fortran module

On 02/04/2016 04:00 PM, Thompson, KT wrote:
> If I run ‘make VERBOSE=1’ with CMake-3.4.3, I see the following command:
> 
> cmake -E cmake_copy_f90_mod src/dir1/dir2/myf90file 
> src/dir1/dir2/CMakeFiles/Lib_FC_f90sub.dir/myf90file.mod.stamp Intel
> 
> but with CMake-3.5.0-rc1, I have this command (notice that no path is
> provided for the filename (argument 3)):
> 
> cmake -E cmake_copy_f90_mod myf90file 
> src/dir1/dir2/CMakeFiles/Lib_FC_f90sub.dir/myf90file.mod.stamp Intel

Thanks.  Here is a fix and a new test case:

 Fix dependency scanning configuration in subdirectories
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5eb21b6

I've queued this for merge to 'release' for inclusion in 3.5.0-rc2.

-Brad

-- 

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] Help for a cmake newbie

2016-02-05 Thread vadtec
Petr,

Thanks for the info. I'm working on getting the builds to work exactly like I 
want for both native *nix and cross-compile Windows builds, so it's a learning 
process. I do appreciate your info.

vadtecvad...@vadtec.net



 On Thu, 04 Feb 2016 01:49:12 -0600 Petr Kmoch  
wrote  

Hi Vadtec.


*The* standard CMake way of dealing with building your dependencies is the 
ExternalProject module ( 
https://cmake.org/cmake/help/latest/module/ExternalProject.html ). It's a huge 
beast, but I belive there are some examples and tutorials available out there.


The gist is: you create a top-level, "superbuild" CMakeLists.txt file which 
will contain only the uses of ExternalProject_Add, one for each dependency, and 
*one for you own project as well.* The dependencies can be downloaded, patched, 
builtt, installed, etc., depending on the parameters you pass to 
ExternalProject_Add. They do not have to be CMake-based; when they are not, 
simply provide an empty (or otherwise project-specific) CONFIGURE_COMMAND 
argument.


When CMake is run on the superbuild, it generates a buildsystem such that 
building it downloads, builds, installs, etc. the external projects. All of 
this happens at build time, not at CMake time.


This way, you have full control over which dependencies you build in what 
order, where they get installed etc. Of course, in your case with dependency 
sources shipped, you don't need a download step (or perhaps maybe just to 
unpack them).


Once you've successfully built the superbuild once, all the dependencies are 
ready, and your own project (which you've set up as just another external 
project) is configured and all its dependencies are in locations which you've 
specified. Now you switch into the binary directory corresponding to your 
project and no longer need to work in the superbuild - each external project is 
self-contained in that it can be used directly as well, without having to go 
through the superbuild.


On a very symbolic level, an external project setup can look something like 
this:


root/CMakeLists.txt:

project(SuperBuild)

include(ExternalProject)


ExternalProject_Add(
  LibraryWeNeed
  PREFIX deps/LibraryWeNeed

  DOWNLOAD_COMMAND somehow_unpack 
${CMAKE_CURRENT_SOURCE_DIR}/deps/LibraryWeNeed.tgz --into 
${CMAKE_CURRENT_BINARY_DIR}/deps/LibraryWeNeed

  BUILD_COMMAND make whatever
  ...
)


ExternalProject_Add(

  MyProjectItself

  PREFIX mybuild

  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src

  DEPENDS LibraryWeNeed

  CMAKE_GENERATOR ${CMAKE_GENERATOR}  # use the same generator as the superbuild

  CMAKE_CACHE_ARGS 
-DLibraryWeNeed_ROOT:PATH=${CMAKE_CURRENT_BINARY_DIR}/deps/LibraryWeNeed
  ...
)



src/CMakeLists.txt:

project(MyProject)

find_package(LibraryWeNeed PATHS ${LibraryWeNeed_ROOT})  # the root path was 
passed in by the superbuild

...



To work with this, you would then do:


cd build

cmake ../root  # generates superbuild

make  # builds superbuild

cd mybuild  # go into MyProject's binary dir

make  # builds MyProject



Once more, this is all very symbolic. Please refer to documentation, tutorials 
etc. to achieve the behaviour you need.


Petr








On Sun, Jan 31, 2016 at 3:42 AM, vadtec  wrote:
Let me start by saying I consider my self a cmake newbie. I've made simple 
makefiles and simple cmake files, but anything more complicated has to this 
point eluded me. Not for a lack of trying, searching, researching, trail, and a 
great deal of error: I simply have not been able to achieve the things I'm 
after. If the sort of questions I'm asking have been answered elsewhere (as I'm 
sure they have), I apologize for asking them again. That being said, I realize 
I'm going to be asking some questions that my Google-Fu has failed me in 
answering. Forgive me my failings, but I'm at my witts end.




I have a project that I'm building on Linux that has a server component and a 
client component that also needs to run on Windows. It uses several libraries 
that I want to version lock so I run into fewer issues with cross compiling and 
feature creep.


The project is laid out like this:


/home
mydir/
project/
build/
bundle/
deps/
curl-7.43.0/
libiconv-1.14/
libpng-1.6.18/
libssh2-1.6.0/
openssl-1.0.2d/
sqlite/
tinycthread/
zlib-1.2.8/
include/
client/
client.h
common/
config.h
common_funcs.h
server/
server.h
src/
client/
client.c
common/
common_funcs.c
server/
server.c


curl, libiconv, libpng, libssh2, and zlib are the libs I want to build and use 
both on Linux and Windows.

[CMake] Running TEST_P from GTest with CMake

2016-02-05 Thread David Doria
I have been successfully using CMake's GTEST_ADD_TESTS to run GTest
TEST and TEST_F blocks defined in a source file. However, I now need
to pass some arguments (filenames that I want CMake to produce
including things like ${CMAKE_SOURCE_DIR}) to the GTests, and it seems
like the way to do this is with INSTANTIATE_TEST_CASE_P that calls
TEST_P blocks with a list of parameters. It seems like GTEST_ADD_TESTS
does not handle this. Does anyone know how to do something like this
through CMake?

Thanks,

David
-- 

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] get_filename_component(var "" ABSOLUTE)

2016-02-05 Thread James Bigler
If I specify an empty value for filename, I get the behavior of relative
path, and var turns into CMAKE_CURRENT_SOURCE_DIR.  It seems like if I put
an empty file I should get back an empty output.

James
-- 

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