[CMake] What are the missing features in Ninja that CMake needs?

2016-12-17 Thread Daniel Carrera
Hello,

Kitware maintains a separate release of Ninja in order to support Fortran:

https://github.com/Kitware/ninja


I kind of want to ask what Kitware changed, but I probably won't understand
the details. Instead, I was hoping someone could give me a toy example of a
Fortran program that cannot be compiled without Kitware's changes to Ninja?

Today I tried to compare CMake+Ninja with Meson+Ninja and both were able to
handle the toy programs that I threw at them. So I haven't found the corner
of the parameter space that is fixed by Kitware's patches.

Cheers,
Daniel.
-- 

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] Ninja+Fortran support for PGI compiler

2016-12-17 Thread Daniel Carrera
On 16 December 2016 at 14:38, Brad King <brad.k...@kitware.com> wrote:

> On 12/15/2016 09:10 PM, Daniel Carrera wrote:
> > set(CMAKE_Fortran_PREPROCESS_SOURCE
> > " -Mpreprocess-E
>  > ")
> >
> > I added that line to PGI-Fortran.cmake and it seems to work.
>
> Great!  I'll integrate that for CMake 3.8.
>
>

Awesome!

Look... I just tested the Oracle compiler. I don't actually use it myself
but I have it installed and it also has problems with CMake + Ninja. It
looks like the same problem. So again I went to Modules/Compiler but this
time I did not see an obvious .cmake file for Oracle. If you want to try to
add Oracle to the list of compilers that CMake knows about, this might help:

1) Free download:

http://www.oracle.com/technetwork/server-storage/developerstudio/downloads/index.html


2) To identify the compiler, the -V flag should help:

$ f90 -V
f90: Studio 12.5 Fortran 95 8.8 Linux_i386 2016/05/31


3) This is how you pre-process sources:

$ f90 -fpp -F foo.f90 -o output_file


Cheers,
Daniel.
-- 

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] Ninja+Fortran support for PGI compiler

2016-12-16 Thread Daniel Carrera
On 16 December 2016 at 17:18, Bill Hoffman  wrote:

> On 12/16/2016 8:38 AM, Brad King wrote:
>
>> Great!  I'll integrate that for CMake 3.8.
>>
> Daniel, do you think you could setup a dashboard so this stays working?
> https://cmake.org/testing/
>
> -Bill
>

Ok. I'll try. I need some help with the script:

# Client maintainer: m...@mydomain.net
set(CTEST_SITE "machine.site")
set(CTEST_BUILD_NAME "pgfortran")
set(CTEST_BUILD_CONFIGURATION Debug)
set(CTEST_CMAKE_GENERATOR "Ninja")
include(${CTEST_SCRIPT_DIRECTORY}/cmake_common.cmake)


What should I write for "machine.site"?

FYI, I will change computer in two months and I will forget to set this up
again. You might want to add PGI to your own nightly tests. The PGI
"community edition" is free. That's the one I have.

https://www.pgroup.com/products/community.htm

Cheers,
Daniel.
-- 

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] Ninja+Fortran support for PGI compiler (was: Bug in Kitware's release of Ninja when compiling with PGI Fortran)

2016-12-15 Thread Daniel Carrera
On 15 December 2016 at 17:35, Brad King  wrote:

>
> This is not a problem with Ninja or our branch of it, but rather with
> CMake's information about the PGI Fortran compiler not being updated
> to support the Ninja generator.  One can see the value for a few other
> compilers (from commit 39ebfc79e614dc395d5ace2ad5818b3ba75ca478):
>
> ```
> $ git grep -A 1 Fortran_PREPROCESS_SOURCE
> Modules/Compiler/GNU-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/GNU-Fortran.cmake-  " -cpp
>-E  -o ")
> --
> Modules/Compiler/Intel-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/Intel-Fortran.cmake-  " -fpp
>-E  > ")
> --
> Modules/Compiler/SunPro-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/SunPro-Fortran.cmake-  "
>-F  -o ")
> ```
>
> The `Modules/Compiler/PGI-Fortran.cmake` module needs to be updated too.
> I don't have that compiler handy, so if you can figure out the appropriate
> line to add to that file, please try it out.  If you get it working please
> post it and Cc me so it can be integrated.
>


Ok... keeping in mind that I don't know much about CMake or PGI, this seems
to be the correct line:

set(CMAKE_Fortran_PREPROCESS_SOURCE
" -Mpreprocess-E
 > ")


The PGI documentation says that -Mpreprocess "instructs the compiler to
perform cpp-like preprocessing on assembly and Fortran input source files".
The -E flag causes the compiler to spit the result to stdout instead of
saving it to a file. Since the -E flag behaves as in the Intel compiler, I
used copied the stdout redirect ">" from the Intel-Fortran.cmake example.

I added that line to PGI-Fortran.cmake and it seems to work. CMake can now
make Ninja files for PGI.

Cheers,
Daniel.
-- 

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] make superclean target? (i.e. clear *everything*)

2013-04-04 Thread Daniel Carrera
Hi all,

Is it possible to ask CMake to make another make clean target that
clears *all* the CMake generated files including the cache? I am a bit
annoyed that the only way to clear everything is to basically run rm
-rf *.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal:
cat /usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] make superclean target? (i.e. clear *everything*)

2013-04-04 Thread Daniel Carrera
On 4 April 2013 11:40, Ansis Māliņš ansis.mal...@gmail.com wrote:
 What would be the benefit of such a command besides syntax?

Only a small convenience, nothing big. I am used to typing make
cleann when I want to make sure that I am starting from a clean
slate. I also have my shell configured so that it warns me when I type
rm -rf *. I generally appreciate the warning but I want to make an
exception for the build directory.


--
Lord of the rings calendar in your Linux/Unix/Mac terminal:
cat /usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] make superclean target? (i.e. clear *everything*)

2013-04-04 Thread Daniel Carrera
On 4 April 2013 11:41, Eric Noulard eric.noul...@gmail.com wrote:
 You can perfectly add a custom target/command to do that,
 if you do out-of-source build then removing the build dir is ok.

Thanks. Yes, I am doing out of source builds.

 Now, this would be a one-shot suicidal target since this will
 basically erase the build tool file (VS project, Makefile, ...)
 which is needed to launch itself :-]

Why is it suicidal? The Makefile doesn't mean anything. All the
intelligence is in CMakeLists.txt.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal:
cat /usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] make superclean target? (i.e. clear *everything*)

2013-04-04 Thread Daniel Carrera
On 4 April 2013 12:41, Eric Noulard eric.noul...@gmail.com wrote:
 Yes I know.
 By suicidal I mean that the built tool will remove its own file
 (but not the CMakeLists.txt off course).

I see what you mean. The Makefile is killing itself. It is committing suicide.

Would it be a reasonable idea to delete CMakeCache.txt and maybe even
CMakeFiles but leaving Makefile intact?

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] make superclean target? (i.e. clear *everything*)

2013-04-04 Thread Daniel Carrera
On 4 April 2013 17:32, Matthew Woehlke matthew.woeh...@kitware.com wrote:

 cd ..
 rm -rf build
 mkdir build
 cd build

 ...? ;-)

 (If your build directories tend to be in the same place, you could easily
 write a shell function to do this, to save typing.)

Done.

I should have thought of that.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Compiling object files.

2013-04-03 Thread Daniel Carrera
Hello,

Summary: How do I use CMake to compile object files? Or is this the
wrong question to ask? (i.e. *should* I be compiling object files?)

Details:
-
I am starting to learn CMake, so I am not even sure I am formulating
my questions the right way... I have a large Makefile that I want to
try to convert to CMake. I did not write the Makefile and I know
little about build systems. But I am interested in CMake and I want to
experiment anyway. My first question is how to convert something like
this:

cparam.o:  cparam.f90 cparam.local cparam.inc cparam_pencils.inc
if [  ]; then \
rm -f cparam.inc; \
rm -f cparam_pencils.inc; \
ln -s cparam.inc cparam.inc; \
ln -s cparam_pencils.inc cparam_pencils.inc; \
fi
$(FC) $(FFLAGS) $(FFLAGS_GENERAL) $(F90FLAGS) -o cparam.o -c cparam.f90


I cannot imagine what the if statement could possibly accomplish, but
I trust that CMake would make the whole thing unnecessary. So I figure
(hope) that all I have to do is tell CMake to make the object file
cparam.o. The problem is that I cannot find anything in the
instructions for making object files. All I see is commands like:


add_executable(hello  hello.f90 world.f90)

add_library(particles backend.f90 vector.f90 const.f90)


There is no add_object function or anything like it... Maybe I am
going about it the wrong way. Maybe I should not be thinking in terms
of making object files at all. Perhaps I should be planning to do
something like:

add_executable(myprogram ${HUGE_LIST_OF_200_FILES})

My worry with this approach is that I see no room to convert the
Makefile incrementally. I was thinking of compiling just one object
file, check that that works and has the right symbols, and then move
to the next object file. Whereas this other option looks like an all
or nothing proposition.

I would welcome any words of advice here.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal:
cat /usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Compiling object files.

2013-04-03 Thread Daniel Carrera
Hi Johannes,

On 3 April 2013 17:44, Johannes Zarl johannes.z...@jku.at wrote:
 Short answer: normally you don't and you shouldn't add statements to compile
 object files.

 CMake is a build system generator, not a build-system in itself. I.e. you only
 tell cmake I want to build library A from source files a.cpp and b.cpp, and I
 want to link my application C , which is created from c.cpp, to the library
 A. CMake then generates the build system (e.g. Makefiles or a Visual Studio
 solution) for you.

Thanks. I guess that makes sense.


 If you have problems with the terminology and concepts behind cmake, I would
 recommend browsing through the wiki (
 http://www.cmake.org/Wiki/CMake#Basic_Introductions ). While it can be
 overwhelming at first, there is a wealth of information to be found there.

Thanks. I have been impressed by the quantity of CMake documentation.
There is not as much for Fortran, but I think that by now I've learnt
most of the Fortran-specific stuff. I will keep reading through the
docs. As you said, it is a bit overwhelming at first.


 There is no add_object function or anything like it... Maybe I am
 going about it the wrong way. Maybe I should not be thinking in terms
 of making object files at all. Perhaps I should be planning to do
 something like:

 add_executable(myprogram ${HUGE_LIST_OF_200_FILES})

 That's the right way to go. Although if you have over 200 input files, you
 might want to group them into libraries if that's appropriate.


Thanks. At least now I have the right idea. I think I will try to come
up with logical groupings that can be turned into libraries.


 Converting incrementally can't be done IMO (at least not without significant
 overhead). Since you would probably use the Makefile generator of cmake, you
 would probably just end up with cmake overwriting your makefiles or similar
 problems.


I don't mean that I expect to compile the entire program with a
half-Makefile, half-CMake system. I like your idea of making
libraries. If I can make a library with a handful of files and I can
verify that the compile didn't fail and the library has the correct
symbols, I would call that a successful incremental step.

 I hope that cleared up some of the confusion. Please do ask again if there are
 problems...

Very helpful. Thanks.

Cheers,
Daniel.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Quick question: CMAKE_CXX_FLAGS vs CMAKE_CXX_COMPILE_FLAGS

2013-04-02 Thread Daniel Carrera
Hi everyone,

What is the difference between CMAKE_CXX_COMPILE_FLAGS and CMAKE_CXX_FLAGS?

The wiki only mentions CMAKE_CXX_FLAGS and CMAKE_C_FLAGS, and those
are clearly used for compiling. But if you Google for CMake examples
(e.g with MPI) you will quickly find CMake scripts that have
CMAKE_CXX_COMPILE_FLAGS.

I am experimenting with CMake and I want to figure out if I should be
using CMAKE_Fortran_FLAGS or CMAKE_Fortran_COMPILE_FLAGS.

Thanks for the help.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to configure Fortran compiler, flags, and so on.

2013-04-02 Thread Daniel Carrera
Thanks!

On 2 April 2013 10:46, Yngve Inntjore Levinsen yngve.levin...@gmail.com wrote:
 Hi,

 If you define variables in your environment before configuring cmake
 they will be read by cmake.

 The following environment variables (maybe I forget some) are relevant
 for fortran code:
 FC = fortran compiler
 FFLAGS = fortran flags (added to default flags)
 LDFLAGS = linker flags (any language)

 In addition, you can read any variables you want in your cmake script
 using $ENV{}, for example

 set(MY_FFLAGS_DOUBLE $ENV{FFLAGS_DOUBLE})

 Note, if you already have run cmake once in your build folder, it will
 ignore FFLAGS etc and use the cached variables. Hence I would recommend
 to protect these ENV{} calls in if defined clauses to get same behaviour:

 if(NOT DEFINED MY_FFLAGS_DOUBLE)
set(MY_FFLAGS_DOUBLE $ENV{FFLAGS_DOUBLE} CACHE STRING Fortran double
 flags)
 endif()

 Here I also added CACHE so that this variable is stored for next runs
 of cmake. I think this is close to what you are asking for (and is the
 same behaviour you will have for FFLAGS and friends).

 Hope this helps!

 Cheers,
 Yngve

 On 31. mars 2013 01:33, Daniel Carrera wrote:
 Hello all,

 I am starting to learn about CMake. So far I have only written very
 minimal CMakeLists.txt files. I am wondering how hard it would be to
 make CMake read some configuration options for Fortran 95 from an
 external file similar to this:

  myprogram.conf 
 FC = mpif90
 F77 = $(FC)
 FFLAGS = -fbounds-check -I/usr/lib/openmpi/include/
 FFLAGS_DOUBLE = -fdefault-real-8


 The end users are largely the developers. The program is recompiled
 and rerun regularly and these settings rarely change, so they need to
 be in some sort of global config file. I was thinking that it might
 make sense to write a thin shell script wrapper around CMake that
 basically does this:

 source $CONF_PATH/myprogram.conf
 cmake $SOURCE_PATH


 So then all those settings become environment variables. And then I'd
 do something inside CMakeLists.txt to make sure that CMake uses the
 contents of those variables to compile the program.

 Am I on the right track here? Or am I just badly re-inventing the
 wheel? If I am on the right track, can someone show me how I would get
 CMake to use these variables? I have tried to find documentation, but
 what I've found seems specific to C/C++:

 http://www.cmake.org/Wiki/CMake_Useful_Variables

 Thanks for the help.

 Cheers,
 Daniel.
 --
 Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
 /usr/share/calendar/calendar.lotr
 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake

 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake



-- 
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to let the user select the compiler and compiler flags.

2013-04-01 Thread Daniel Carrera
Hi all,

I am just getting started with CMake. Here is my question: Is there a
good way to have an external config file that specifies both the
compiler an compile flags?

The program is compiled many times, and it makes sense to have the
compiler and flags in a config file rather than have them in the
command line. I am hoping to use CMake itself as the language of the
config file. For example:

# -   myprogram.cmake -
# Local configuration file.

set (CMAKE_Fortran_COMPILER  mpif90)
set (CMAKE_Fortran_FLAGS -fdefault-real-8)
set (CMAKE_Fortran_FLAGS_DEBUG   -O0 -g -fbounds-check)
set (CMAKE_Fortran_FLAGS_RELEASE -O3)
set (CMAKE_BUILD_TYPE RELEASE)


I think this would be a useful config file and I can just include it
in CMakeLists.txt. The problem is that the compiler must be specified
before I run project(), while the compile flags must be specified
AFTER project():


cmake_minimum_required (VERSION 2.8)
include (path/to/myprogram.cmake)
enable_language (Fortran)
project (MyProgram)


At this point all the compile flags have been overwritten by
enable_language() and project().  Can anyone suggest a good solution?
I have a few ideas, but I am not sure about them:

1) I could give up on the idea of using CMake in the config file. The
config file could be a shell script that sets some environment
variables. My understanding is that this will work, but you would lose
the flexibility of CMake.

2) I could load the config file twice. Once before, and once after
project(). I am not sure if this would have any unexpected
side-effects.

3) I could store the flags in the cache. But I am not sure if
overwriting the cache is a good idea or not.

4) I could use a shell script to split the config file into the
compiler part and everything else, and then load them separately. I
think I like this option, but I am not fully aware of the
side-effects.

Does anyone have any words of advice or wisdom to share with me?

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to let the user select the compiler and compiler flags.

2013-04-01 Thread Daniel Carrera
Hi David,

Thanks. That seems to work well. I tweaked your idea to allow the user
to have two different config files. To do that, instead of using -C, I
have two include lines in my CMakeLists.txt. It seems to work well.
I just have to make sure I explain clearly which file takes
precedence.

Cheers,
Daniel.




On 1 April 2013 16:34, David Cole dlrd...@aol.com wrote:
 Do use CACHE with your set statements to put them in the cache, and then use 
 the -C command line argument to prime the cache with your file, rather than 
 including it in your CMakeLists file.

 That should have the effect you're seeking...

 HTH,
 David C.


 On Apr 1, 2013, at 3:54 AM, Daniel Carrera dcarr...@gmail.com wrote:

 Hi all,

 I am just getting started with CMake. Here is my question: Is there a
 good way to have an external config file that specifies both the
 compiler an compile flags?

 The program is compiled many times, and it makes sense to have the
 compiler and flags in a config file rather than have them in the
 command line. I am hoping to use CMake itself as the language of the
 config file. For example:

 # -   myprogram.cmake -
 # Local configuration file.

 set (CMAKE_Fortran_COMPILER  mpif90)
 set (CMAKE_Fortran_FLAGS -fdefault-real-8)
 set (CMAKE_Fortran_FLAGS_DEBUG   -O0 -g -fbounds-check)
 set (CMAKE_Fortran_FLAGS_RELEASE -O3)
 set (CMAKE_BUILD_TYPE RELEASE)


 I think this would be a useful config file and I can just include it
 in CMakeLists.txt. The problem is that the compiler must be specified
 before I run project(), while the compile flags must be specified
 AFTER project():


 cmake_minimum_required (VERSION 2.8)
 include (path/to/myprogram.cmake)
 enable_language (Fortran)
 project (MyProgram)


 At this point all the compile flags have been overwritten by
 enable_language() and project().  Can anyone suggest a good solution?
 I have a few ideas, but I am not sure about them:

 1) I could give up on the idea of using CMake in the config file. The
 config file could be a shell script that sets some environment
 variables. My understanding is that this will work, but you would lose
 the flexibility of CMake.

 2) I could load the config file twice. Once before, and once after
 project(). I am not sure if this would have any unexpected
 side-effects.

 3) I could store the flags in the cache. But I am not sure if
 overwriting the cache is a good idea or not.

 4) I could use a shell script to split the config file into the
 compiler part and everything else, and then load them separately. I
 think I like this option, but I am not fully aware of the
 side-effects.

 Does anyone have any words of advice or wisdom to share with me?

 Cheers,
 Daniel.
 --
 Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
 /usr/share/calendar/calendar.lotr
 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake



-- 
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to configure Fortran compiler, flags, and so on.

2013-03-30 Thread Daniel Carrera
Hello all,

I am starting to learn about CMake. So far I have only written very
minimal CMakeLists.txt files. I am wondering how hard it would be to
make CMake read some configuration options for Fortran 95 from an
external file similar to this:

 myprogram.conf 
FC = mpif90
F77 = $(FC)
FFLAGS = -fbounds-check -I/usr/lib/openmpi/include/
FFLAGS_DOUBLE = -fdefault-real-8


The end users are largely the developers. The program is recompiled
and rerun regularly and these settings rarely change, so they need to
be in some sort of global config file. I was thinking that it might
make sense to write a thin shell script wrapper around CMake that
basically does this:

source $CONF_PATH/myprogram.conf
cmake $SOURCE_PATH


So then all those settings become environment variables. And then I'd
do something inside CMakeLists.txt to make sure that CMake uses the
contents of those variables to compile the program.

Am I on the right track here? Or am I just badly re-inventing the
wheel? If I am on the right track, can someone show me how I would get
CMake to use these variables? I have tried to find documentation, but
what I've found seems specific to C/C++:

http://www.cmake.org/Wiki/CMake_Useful_Variables

Thanks for the help.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal: cat
/usr/share/calendar/calendar.lotr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake