[CMake] Exclude custom install target(s) from all

2013-05-10 Thread Jeet Sukumaran

Hi all,

I have a library that is built and linked to as part of my project. I 
want to provide the facility to OPTIONALLY have the library installed 
system-wide (or wherever ${CMAKE_INSTALL_PREFIX} is set). Otherwise, by 
default, the project's final build products will be linked statically to 
the library, and the former get installed, but the library binaries stay 
in the build directory.


In other words:

$ make
$ make install

will build and install, the programs, but only something like

$ make install.foo

will install the library to ${CMAKE_INSTALL_PREFIX}, building it first 
if needed.


I have something like this so far (simplified from the actual script, so 
there might be errors):



INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_LIST_DIR}")
SET (FOO_LIBRARY "foo")

# Following builds library and makes it available to
# be linked other targets within project by:
# TARGET_LINK_LIBRARIES(${progname} ${FOO_LIBRARY})
ADD_LIBRARY(${FOO_LIBRARY}
foo/foo.cpp # and other sources ...
)

###
# Approach #1
# ---
# Optionally allow users to install it by invoking:
#
#   cmake .. -DINSTALL_FOO="yes"
#
# This works, but it means that users will have to run
# cmake again to switch back and forth between the libary
# installation and non-library installation.
#
OPTION(INSTALL_FOO "Install foo" OFF)
IF (INSTALL_FOO)
INSTALL(TARGETS ${FOO_LIBRARY} DESTINATION lib/foo)
SET(FOO_HEADERS foo/foo.h)
INSTALL(FILES ${FOO_HEADERS} DESTINATION include/foo)
UNSET(INSTALL_FOO CACHE)
ENDIF()
###

###
# Approach #2
# ---
# Optionally allow users to install it by invoking:
#
#   make install.foo
#
# Unfortunately, this gets installed by "make install",
# which I want to avoid
SET(FOO_INSTALL "install.foo")
ADD_CUSTOM_TARGET(${FOO_INSTALL}
COMMAND ${CMAKE_COMMAND}
-D COMPONENT=foo
-P cmake_install.cmake)
ADD_DEPENDENCIES(${FOO_INSTALL} ${FOO_LIBRARY})
INSTALL(TARGETS ${FOO_LIBRRARY}
DESTINATION lib/foo COMPONENT foo)
SET(FOO_HEADERS foo/foo.h)
INSTALL(FILES ${FOO_HEADERS}
DESTINATION include/foo COMPONENT foo)
###

As can be seen, approach #1 sort of works, but the required steps to 
install the library are:


$ cmake .. -DINSTALL_FOO="yes"
$ make && make install

And then, to go back to "normal" builds, the user has to remember to run 
cmake again without the "-DINSTALL_FOO" option, otherwise the library 
will be installed on the next "make install".


The second approach works when I run "make install.foo", but it also 
install the library if I run "make install". I would like to avoid the 
latter.


Does anyone have any suggestions on how to go about achieving this?

Thanks!


-- jeet



--
Jeet Sukumaran
--
jeet.sukuma...@duke.edu
--
Department of Biology
Duke University
Box 90338
Durham, NC 27708
--
Blog/Personal Pages:
   http://jeetworks.org/
Photograph Galleries:
   http://jeet.smugmug.com/
GitHub Repositories:
   http://github.com/jeetsukumaran
--

--

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 install Fortran module files?

2013-05-10 Thread Yngve Inntjore Levinsen
Hi,

If you set the CMAKE_Fortran_MODULE_DIRECTORY variable, then all module
files by default will be built into this folder. In our case we set this
to ${CMAKE_BINARY_DIR}/fortran. Since nothing else is in this folder,
you have a fairly good control over where your mod files are if you want
to install them afterwards...

I haven't really tried to install these myself, but I would imagine it
should simply be
install(DIRECTORY ${CMAKE_BINARY_DIR}/fortran DESTINATION
include/fortran/project)
(or wherever you want the module files relative to the install prefix..
Is there a correct place for them?)

Hope this helps you along somewhat.

Cheers,
Yngve

Den 10. mai 2013 19:24, skrev Neil Carlson:
> I'm trying to figure out how to install the module (.mod) files that
> are generated by the Fortran compiler.  I've only found one thread on
> the topic from 3 years ago.  The solution there was to find the
> appropriate directory in the build tree where these files were created
> and scarf up everything there that looked right and copy them to the
> desired install dir.  It looks really fragile.  Has cmake introduced
> any tools/hooks in the meantime that would simplify this, is is that
> still the way it has to be done?  I'd be interested in hearing from
> anyone that has a working solution.
>
> Thanks!
>   Neil
>
>
> --
>
> 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

[CMake] Thanx for fixing visual studio doing the install even though the build failed

2013-05-10 Thread J Decker
Just a thank you note; I'm noticing that with the latest version, that
when I build the install target, it doesn't do the install if the
build failed.  It previously would go through the install (especially
if a previous build had succeeded) which ran all the error output off
the screen.
--

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 install Fortran module files?

2013-05-10 Thread Neil Carlson
I'm trying to figure out how to install the module (.mod) files that are
generated by the Fortran compiler.  I've only found one thread on the topic
from 3 years ago.  The solution there was to find the appropriate directory
in the build tree where these files were created and scarf up everything
there that looked right and copy them to the desired install dir.  It looks
really fragile.  Has cmake introduced any tools/hooks in the meantime that
would simplify this, is is that still the way it has to be done?  I'd be
interested in hearing from anyone that has a working solution.

Thanks!
  Neil
--

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] Problem installing symbolic links on Mac OS X

2013-05-10 Thread Cory Quammen
Thanks, Sean.

On Fri, May 10, 2013 at 12:41 PM, Sean McBride  wrote:
> On Fri, 10 May 2013 12:34:06 -0400, Cory Quammen said:
>
>>I am running Mac OS X 10.7.5 . When I installed CMake 2.8.10.2 just
>>now, it failed to create symbolic links to the cmake executables in
>>the default location because I had symbolic links with the same names
>>already installed by a previous version of CMake.
>
> This is a known bug:
> 
>
> IMNSHO, the best thing to do is fix:
> 
>
> Cheers,
>
> --
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com
> Mac Software Developer  Montréal, Québec, Canada
>
>



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill
--

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] Problem installing symbolic links on Mac OS X

2013-05-10 Thread Sean McBride
On Fri, 10 May 2013 12:34:06 -0400, Cory Quammen said:

>I am running Mac OS X 10.7.5 . When I installed CMake 2.8.10.2 just
>now, it failed to create symbolic links to the cmake executables in
>the default location because I had symbolic links with the same names
>already installed by a previous version of CMake.

This is a known bug:


IMNSHO, the best thing to do is fix:


Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada


--

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] Problem installing symbolic links on Mac OS X

2013-05-10 Thread Cory Quammen
Oops, I failed to mention that the symbolic links I am talking about
are in /usr/bin, e.g., /usr/bin/cmake, /usr/bin/ctest, etc.

On Fri, May 10, 2013 at 12:34 PM, Cory Quammen  wrote:
> Hi all,
>
> I am running Mac OS X 10.7.5 . When I installed CMake 2.8.10.2 just
> now, it failed to create symbolic links to the cmake executables in
> the default location because I had symbolic links with the same names
> already installed by a previous version of CMake. Removing the
> offending links and re-running the installer fixes the problem.
>
> I just wanted to let folks know about this in case it isn't intended
> behavior. It would be great if I could tell the installer to overwrite
> existing links.
>
> Thanks,
> Cory
>
> --
> Cory Quammen
> Research Associate
> Department of Computer Science
> The University of North Carolina at Chapel Hill



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill
--

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] Problem installing symbolic links on Mac OS X

2013-05-10 Thread Cory Quammen
Hi all,

I am running Mac OS X 10.7.5 . When I installed CMake 2.8.10.2 just
now, it failed to create symbolic links to the cmake executables in
the default location because I had symbolic links with the same names
already installed by a previous version of CMake. Removing the
offending links and re-running the installer fixes the problem.

I just wanted to let folks know about this in case it isn't intended
behavior. It would be great if I could tell the installer to overwrite
existing links.

Thanks,
Cory

--
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill
--

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] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Paul Smith
On Fri, 2013-05-10 at 11:34 -0400, Brad King wrote:
> On 05/10/2013 11:23 AM, Paul Smith wrote:
> > Is there any way to work around this?  I've tried setting
> > CMAKE_CONFIGURATION_TYPES before project()
> 
> Make sure you set it as a cache entry:
> 
>  set(CMAKE_CONFIGURATION_TYPES
>"Debug;Release;MinSizeRel;RelWithDebInfo"
>CACHE STRING "Supported configs")
>  project(MyProject NONE)
>  enable_language(C)
>  enable_language(CXX)

I definitely did cache it (without that it has no effect).  In my
super-simple test case (which looks like yours) it works fine.

But in my real project when I do it this way, I do see all the
configuration types listed in the CMakeCache.txt file, but I also get
all those error messages about "internal CMake variable not set" for
each of the MINSIZEREL build type variables.  I double-checked and there
are no errors for the other types, including RelWithDebInfo.

This behaves identically with 2.8.11-rc4 BTW.

--

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] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Brad King
On 05/10/2013 11:23 AM, Paul Smith wrote:
> Is there any way to work around this?  I've tried setting
> CMAKE_CONFIGURATION_TYPES before project()

Make sure you set it as a cache entry:

 set(CMAKE_CONFIGURATION_TYPES
   "Debug;Release;MinSizeRel;RelWithDebInfo"
   CACHE STRING "Supported configs")
 project(MyProject NONE)
 enable_language(C)
 enable_language(CXX)

-Brad
--

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] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Paul Smith
On Fri, 2013-05-10 at 11:14 -0400, Brad King wrote:
> On 05/10/2013 10:31 AM, Paul Smith wrote:
> > I've separated my project statement from:
> > 
> >   project(MyProject C CXX)
> > 
> > into:
> > 
> >   project(MyProject NONE)
> >   enable_language(C)
> >   enable_language(CXX)
> > 
> > on Windows (VS 10 Win64 generator):
> > 
> >   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
> > 
> > and after the above change it's:
> > 
> >   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release
> 
> It looks like this behavior has been in there for a *long* time.

Yes, I was just coming back to confirm it still happens with CMake
2.8.11-rc4.

Is there any way to work around this?  I've tried setting
CMAKE_CONFIGURATION_TYPES before project(), after project and before
enable_language(), and after enable_language() and nothing works.

:-(.


The only thing I've tried so far that seems to work on Windows (haven't
gone back to try it on the other platforms) is to put the project()
definition inside an if():

  if(WIN32)
  project(MyProject C CXX)
  else()
  project(MyProject NONE)
  endif()
   ...
  if(NOT WIN32)
  enable_language(C)
  enable_language(CXX)
  endif()

I don't know if this will have other bad effects.  It surely is
unpleasant.

--

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] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Brad King
On 05/10/2013 10:31 AM, Paul Smith wrote:
> I've separated my project statement from:
> 
>   project(MyProject C CXX)
> 
> into:
> 
>   project(MyProject NONE)
>   enable_language(C)
>   enable_language(CXX)
> 
> on Windows (VS 10 Win64 generator):
> 
>   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
> 
> and after the above change it's:
> 
>   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release

It looks like this behavior has been in there for a *long* time.
The VS generator selects the list of configurations here:

 
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalVisualStudio7Generator.cxx;hb=v2.8.10.2#l36

In the case that project enables languages then the first
EnableLanguage call there loads

 
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-MSVC.cmake;hb=v2.8.10.2#l52

which selects the full configuration list.  In the case that the
project enables only "NONE" then the configuration list is not
initialized and falls through to the call to GenerateConfigurations:

 
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalVisualStudio7Generator.cxx;hb=v2.8.10.2#l136

which selects only Debug and Release.

OTOH the Xcode generator just initializes all four configurations
in EnableLanguage up front:

 
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalXCodeGenerator.cxx;hb=v2.8.10.2#l182

-Brad
--

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] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Paul Smith
Er... I take it back about being able to set the value by hand.  If I do
so I get a TON of errors, for each of the builtin variable variants for
MinSizeRel and RelWithDebInfo (e.g., CMAKE_C_FLAGS_MINRELSIZE / "Error
required internal CMake variable not set").

Now I'm not sure what to do.


On Fri, 2013-05-10 at 10:31 -0400, Paul Smith wrote:
> Hi all.  I'm using cmake 2.8.10.2.  I'm trying to introduce an
> alternative compiler into my build system for Linux, so as a first step
> I've separated my project statement from:
> 
>   project(MyProject C CXX)
> 
> into:
> 
>   project(MyProject NONE)
>   enable_language(C)
>   enable_language(CXX)
> 
> This works fine on Linux (makefile generator) and MacOSX (XCode
> generator): cmake and build and test work.  But on Windows (VS 10 Win64
> generator) cmake succeeds, but running the resulting project file does
> not work: it fails immediately.  Looking at the CMakeCache.txt file I
> can see that two of the default CMAKE_CONFIGURATION_TYPES settings are
> missing; the cached value from before I made the above change is:
> 
>   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
> 
> and after the above change it's:
> 
>   CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release
> 
> The failure happens because our default build type is RelWithDebInfo
> which of course doesn't exist.
> 
> I didn't change anything else and we don't set this variable anywhere in
> our cmake files.
> 
> I guess I can go in and set this by hand, but anyone have any ideas why
> it disappeared, and if this is a bug?
> 
> --
> 
> 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


[CMake] Missing CMAKE_CONFIGURATION_TYPES with project NONE on Windows

2013-05-10 Thread Paul Smith
Hi all.  I'm using cmake 2.8.10.2.  I'm trying to introduce an
alternative compiler into my build system for Linux, so as a first step
I've separated my project statement from:

  project(MyProject C CXX)

into:

  project(MyProject NONE)
  enable_language(C)
  enable_language(CXX)

This works fine on Linux (makefile generator) and MacOSX (XCode
generator): cmake and build and test work.  But on Windows (VS 10 Win64
generator) cmake succeeds, but running the resulting project file does
not work: it fails immediately.  Looking at the CMakeCache.txt file I
can see that two of the default CMAKE_CONFIGURATION_TYPES settings are
missing; the cached value from before I made the above change is:

  CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo

and after the above change it's:

  CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release

The failure happens because our default build type is RelWithDebInfo
which of course doesn't exist.

I didn't change anything else and we don't set this variable anywhere in
our cmake files.

I guess I can go in and set this by hand, but anyone have any ideas why
it disappeared, and if this is a bug?

--

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