[CMake] Feature req: Project-specified mandatory variables

2017-11-11 Thread Oliver Smith
Consider the following:

PROJECT(Mandatory)

SET(USING_SHAPE "" CACHE STRING "[Required] Shape config: Round or
Square")
SET_PROPERTY(CACHE USING_SHAPE PROPERTY STRINGS Round Square)
IF (NOT USING_SHAPE)
  MESSAGE(FATAL_ERROR "'USING_SHAPE' variable is required but was not
set. Choose Round or Square")
ENDIF ()

MESSAGE(STATUS "Shape config: ${USING_SHAPE}")
...

The first time a user runs cmake here, they will receive a wall of text
about compiler identification, followed by a complex error message that
most developers can probably parse, but it's poorly suited for other people
participating in a larger build system. etc.

This leads to a common case where teams wrap their cmake invocation behind
one or more script layers to hoist the setting checks out of the scripts.

Consider:

PROJECT(Mandatory)

EXTERNAL_VALUE(   # or it could be 'set' with a special case for
'FATAL_ERROR' as the default
USING_SHAPE  FATAL_ERROR
"Shape config"
STRINGS Round Square
)
MESSAGE(STATUS "Shape config: ${USING_SHAPE}")

The CMake GUI(s) could also pick up on these and prompt the user for them
at the start of the config state.

Other wordings:

SET(USING_SHAPE FATAL_ERROR "Shape Config" ...)
MANDATORY(USING_SHAPE "Shape Config ...)
REQUIRE_SETTING
REQUIRE_VARIABLE
REQUIRED_VARIABLE
-- 

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] Need to prepend compiler with static analysis tool

2012-05-23 Thread Oliver Smith

On 5/23/2012 4:45 PM, jrosensw wrote:

Hi Alexander,

I tried this already.  However I'm not sure what a "clean build tree"
means.  Maybe thats my problems.  All I did was this:

CXX="/insure/g++" cmake .

But when I compiled I did not see a change.  How do I get my tree to a
"clean state"?  Other than running "make clean" which I did do.


rm -rf CMakeCache* CMakeFiles*

- Oliver


--

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] Couple of library/link questions

2012-03-20 Thread Oliver Smith
I'm trying to make a CMakeLists for libevent, and had a couple of 
questions that would make it a bit cleaner:


- Other than using a macro to do { add_executable(...) 
target_link_libraries(...) } is there a /clean/ way to make everything 
in a subdirectory automatically link a given library?


- The makefiles I'm basing this on build libevent_core.lib, 
libevent_extras.lib and then libevent.lib which is basically the two 
previous libraries merged.


I wanted to do:

ADD_LIBRARY(libevent_core ${CoreSrcFiles})
ADD_LIBRARY(libevent_extras ${ExtraSrcFiles})
ADD_LIBRARY(libevent)
TARGET_LINK_LIBRARIES(libevent libevent_core libevent_extras)

but this generates a warning/error,  listing the two libraries in 
add_library doesn't work either.


So for now I have

ADD_LIBRARY(libevent_core ${CoreSrcFiles})
ADD_LIBRARY(libevent_extras ${ExtraSrcFiles})
ADD_LIBRARY(libevent ${CoreSrcFiles} ${ExtraSrcFiles})

but that's clumsy :)

- Oliver

--

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 with precompiled header attempts

2012-02-26 Thread Oliver Smith
I've spent all day trying to get a single precompiled header to work on 
a series of targets within a rather complex project. I'll profess to a 
fair amount of stabbing in the dark.


I came up with the following, but it doesn't bother building the PCH 
until the *end* of the first target. And then it fails because it 
doesn't have the compiler definitions needed.


So, how do I get my ADD_PCH(targetname) macro to prioritize the PCH 
file, without making it always build the pch?


Note: All of the candidate targets use the project include files, 
compiler flags and definitions.//


8x --- snip --- x8

   SET(_PCH_SRC "${Project_SOURCE_DIR}/cfg/syscfg.h")
   SET(_PCH_HDR ${_PCH_SRC})# Viable as a dependency name.
   IF ( _USE_PCH )
IF (WINDOWS)
SET(_PCH_HDR "${_PCH_SRC}.pch")
ELSE ()
SET(_PCH_HDR "${_PCH_SRC}.gch")
ENDIF()
SET(_pchFlags "${CMAKE_CXX_FLAGS}")
GET_DIRECTORY_PROPERTY(_pcfIncludePaths INCLUDE_DIRECTORIES)
FOREACH (_inc ${_pcfIncludePaths})
LIST(APPEND _pchFlags "-I" ${_inc})
ENDFOREACH()
GET_DIRECTORY_PROPERTY(_pcfIncludePaths COMPILE_DEFINITIONS)
FOREACH (_inc ${_pcfIncludePaths})
LIST(APPEND _pchFlags "-D" ${_inc})
ENDFOREACH()
SEPARATE_ARGUMENTS(_pchFlags)
ADD_CUSTOM_COMMAND(
PRE_BUILD
OUTPUT ${_PCH_HDR}
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} 
${_pchFlags} -o ${_PCH_HDR} ${_PCH_SRC}
MAIN_DEPENDENCY ${_PCH_SRC}
IMPLICIT_DEPENDS CXX ${_PCH_SRC}
DEPENDS ${_PCH_SRC}
)
   ENDIF ( _USE_PCH )

   MACRO(ADD_PCH _TARGET)
 IF ( WW2_USE_PCH )
  MESSAGE(STATUS "Adding pch to ${_TARGET}")
  add_dependencies(${_TARGET} ${_PCH_HDR})
 ENDIF ( )
   ENDMACRO()

8x --- snip --- x8

For bonus points: The business of having to copy the include paths and 
compiler definitions seems really clumsy, it's horribly platform 
dependent. Surely there's a better way say "build it the same way you'd 
build anything else in this directory"


- Oliver

--

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] Partial 3rd-party library management

2012-02-26 Thread Oliver Smith
In order to maximize our ability to rebuild an exact copy of a previous 
revision, our repository carries copies of numerous 3rd party libraries.


However, in most of their cases we are fairly selective about which 
elements we build.


Downside: "make clean && make" winds up rebuilding all the damn libraries :)

At the same time, we have a large number of customized project-wide 
customizations, depending on which client / product version we're 
building for. So, when we are building - as opposed to developing - we 
need the ability to easily perform a full rebuild, including possibly 
the libraries.


For a nominal development "clean" build, upto 70% of the build time is 
spent building 3rd party libraries.


Right now - for simplicity - we actually assemble the 3rd libraries from 
the top level CMakeLists.txt directly (ok, simplicity and a failure on 
my part to work out how to express that "libraryXXX.a" is an output of 
"subfolderX").


/The problem/

Something like a source-control revert can sometimes put /our/ part of 
the code base into a state that requires a clean. However, we don't want 
to cause the libraries to rebuild /except/ when someone changes 
compilation flags or forces a rebuild of the libraries somehow else 
(e.g. a "cleanall" target).


Is there a way to do this with cmake? Or is this problem only because I 
haven't (yet) split these libraries into their own CMakeLists files?


The simplest and therefore easiest complete example I have is:

8x --- snip --- x8
  add_library(ircclient SHARED libircclient/src/libircclient.c)
  set_property(TARGET ircclient PROPERTY COMPILE_DEFINITIONS 
IN_BUILDING_LIBIRC)

  link_directories( ${Project_BINARY_DIR}/ircclient )
8x --- snip --- x8


- Oliver

--

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] Is there a cookbook?

2012-02-24 Thread Oliver Smith

On 2/23/2012 9:37 PM, John Drescher wrote:

You probably want to do some type of file GLOBBING for that


Here is an example of file globbing (along with its pitfalls):

http://www.cmake.org/pipermail/cmake/2010-September/039558.html


I am sorry. It does not look like the code to glob is there. I am to
tired to look for more examples now.

Yep, this morning I was able to piece together what I needed - but my 
point here is that we really need a CMake CookBook or snippet 
repository. I always hit the FAQ first, but that /explains/ when what a 
coder tends to need in that frame of mind is a living example.


I appreciate your time looking for a solution for my issue, though :)

- Oliver

--

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] Is there a cookbook?

2012-02-23 Thread Oliver Smith
So it's late, and suddenly I find I can't remember how to configure 
cmake to compile any .xml file in a specific directory with an 
xml-to-header script we have. More importantly, I can't think of the 
right terms to find an answer, so I've spent a frustrating hour googling 
to no end.


Is there not a cmake cookbook or recipie book someplace? I really don't 
feel like figuring out, yet again, how to tell cmake "for every .xml 
file in ${folder} run ${command} to produce ${output}.h"... :)


- Oliver

--

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] Making a variable a dependency...

2012-02-04 Thread Oliver Smith
My CMakeLists uses the Subversion repository information in a couple of 
places (it configures a file revision.h and it uses it for the CPack 
package name).


The problem is that this variable is cached and retained until the cache 
is rebuilt, instead of being calculated or evaluated per make. So if I 
do a build, then do an svn update and pull some changes, it will build a 
new executable but it will stamp it with the revision number from when 
CMake last regenerated the make files...


Is there a way to mark a variable as volatile or something so that CMake 
will always recalculate it and check if it has changed?



--

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] Revision header

2012-01-21 Thread Oliver Smith
I have a script that generates a revision.h file, I've spent the morning 
trying to figure out how to make it so that ... any time CMake rebuilds 
any of the other targets, it starts by running the make-new-revision script.


The idea is, I use the script manually to upversion, but anytime I type 
"make" and /anything/ has to be done (even just a relink), it will do 
the upversion first.


I've only managed to make it either source dependent or always build, 
which forces the versionNo file to recompile and forces all executables 
to relink, so if you type:


make ; make ... it will have to relink the executables the second time 
because of an pointless upversion :)


- Oliver

--

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] Is there really any cmake support?

2010-03-28 Thread Oliver Smith

On 3/28/2010 5:14 AM, Fred Fred wrote:
This list seems not to be really active and I did not receive any help 
since I posted this one week ago. BTW this issue has been open on 
Mantis more than 3 months ago and seems still to be open! So is there 
really anybody trying to help on cmake??
If the developers were out monitoring every bug-reporting list in the 
universe (such as ITK), there probably wouldn't be any support. To 
answer your question: yes you should post it to the CMake bug reporting 
tool if you want the CMake people to know about it.


If the bug is that mission critical to you, there is always the option 
of downloading the source, fixing the bug, and submitting a patch to the 
CMake developers.


Otherwise - I'd love to know what significantly-cross-platform open 
source projects you've been working on where bug fixes have such a rapid 
turnaround. I've seen fairly critical bug tickets for Ubuntu, GDM, 
Firefox, Thunderbird, OpenOffice and GCC for years. MySQL has had 
several fatal crash bugs open for 2+ years, and their response to a 
major bug introduced by Prepared Statements was, after a year of people 
complaining about it, to remove the default auto-connection behavior to 
"sort of make it go away".


Thus far, I've gotten better support out of the CMake developers than I 
have from several commercial software providers, including Intel.


- Oliver

___
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] One folder to rule them all...

2010-03-24 Thread Oliver Smith
I would like the following [pseudo] CMake package to create a 
"Solution.sln" in ${CMAKE_BINARY_DIR} and put the .vcproj files in 
${CMAKE_BINARY_DIR}/${VCPROJ_DIR}


project (Solution)
add_library(library1 foo1.cpp)
# ...
add_library(library9 foo9.cpp)
add_executable(target1 target1.cpp)
# ...
add_executable(target27 target27.cpp)

I do realize that when your fellow coders "can't find the solution file" 
in a directory window because it has a scroll bar that you should be 
spending time on your resume rather than 'accept'ing the trouble 
ticket... 



___
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] ICC under Linux

2010-03-23 Thread Oliver Smith
When you tell CMake under Linux to use ICC, there's no automatic 
detection of the custom archiver and linker that ICC requires. The 
following lines fix that, but would it be possible to add them to the 
stock CMake files someplace so that using ICC becomes slightly more 
transparent?


# Intel(R) Compiler has its own library archiver,
# if you build libraries and do not use xiar,
# the Intel compiler will complain about invalid
# archives at the link phase.

# The Intel(R) archiver is "xiar" usually
# located in the same folder as the compiler,
# /opt/intel/Compiler/nn/n.nn/ia32/bin/xiar
# for example.

FIND_PROGRAM(XIAR xiar)
IF(XIAR)
  SET(CMAKE_AR "${XIAR}")
ENDIF(XIAR)
MARK_AS_ADVANCED(XIAR)

# Intel(R) Compiler also comes with its own linker
# which provides a number of additional benefits when
# linking code compiled with the Intel(R) compiler.
# Again, usually in the same place as icc itself,

# /opt/intel/COmpiler/nn/n.nn/ia32/bin/xild per e.g

FIND_PROGRAM(XILD xild)
IF(XILD)
  SET(CMAKE_LINKER "${XILD}")
ENDIF(XILD)
MARK_AS_ADVANCED(XILD)


___
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] This has to have been asked before...

2010-03-08 Thread Oliver Smith

On 3/6/2010 8:04 PM, J Decker wrote:

there is a foreach() operator...
   
Well, thanks for trying, but what I actually want to know is how to add 
something to all the current targets /automatically/ - as in without 
specifying them by hand, and how to get the compiler flags etc of a 
particular target so that I can /generate/ a custom command that matches 
the given target.


get_file_component(pchbase ${PrecompiledHeader} NAME_WE)
get_file_component(pchpath ${PrecompiledHeader} PATH)

*foreach ( target in LISTS CMAKE_TARGET_LIST )*

set(pchname "${CMAKE_BINARY_DIR}/${pchbase}.${target}.h")

get_target_properties(defines ${target} COMPILE_DEFINITIONS)
get_target_properties(flags ${target} COMPILE_FLAGS)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS 
"${flags} -include ${pchname} -Winvalid-pch")


add_custom_command(${target} PRE_BUILD COMMAND
"ln -s ${pchname} ${PrecompiledHeader}"
"g++ ${defines} ${flags} -o ${pchname}.gch ${pchname}")
)
endforeach ()

Marked in bold is the part I'm struggling with.

- Oliver

___
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] This has to have been asked before...

2010-03-06 Thread Oliver Smith

On 3/6/2010 6:39 PM, Oliver Smith wrote:
I want to add a target (a gcc precompiled header) as a dependency for 
every target so it'll get compiled with the flags for that particular 
target, including altering the resulting file name.
I should say: /automatically/ add... I don't want to add them by hand :) 
(Project has a lot of targets =/)


- Oliver

___
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] This has to have been asked before...

2010-03-06 Thread Oliver Smith

I'm probably not using the right keywords on my search.

I want to add a target (a gcc precompiled header) as a dependency for 
every target so it'll get compiled with the flags for that particular 
target, including altering the resulting file name.


I did try looking at the precompiled header CMake include, but that just 
confused the bejeezus out of me, not helped by the fact that it didn't 
work :)


- Oliver

___
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] Adding a generated source to all multiple targets

2010-02-23 Thread Oliver Smith
I have a CMake project with a number of targets, and a Lua wrapper 
generated through tolua++ which is included by several of them, so that 
it is compiled with the target-specific make flags per-target.


Global make flags: -O0 -ggdb3 -Wall -Werror ... etc
Target1 make flags: -DAS_DB_PROXY ...
Target2 make flags: -DAS_GAME_SERVER ...
Target3 make flags: -DAS_CLIENT

LuaTarget make flags: -Wno-unused

The LuaTarget is "luapkg.cc" generated from "lua.pkg" via "tolua++ -n 
game -o luapkg.cc luapkg.pkg"


If I add "luapkg.cc" to the list of sources for any given target, CMake 
barfs because luapkg.cc doesn't exist.


I've tried variations of add_custom_target and add_custom_command to no 
avail.


Is there a way to do this with CMake 2.6 or 2.8?

And it occurs to me that if I can find a solution to this, I can 
probably use the same solution for adding a precompiled header to each 
target (for my limited subset of platforms).


- Oliver

___
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] Adding pre-compiled header support easily (add_generated_source)

2010-02-17 Thread Oliver Smith
Adding precompiled header support doesn't have to be a massive amount of 
work.


Fundamentals:

   1. Include the header in every source module,
   2. Compile the header once for every target (so that compiler flags 
match),


There are three possible build environments:

   1. Full precompiled header support
   2. Precompiled header support for a non-PCH aware source tree,
   3. No precompiled header support,

Lets deal with #1 first; there will be a precompiled header file that 
needs compiling ahead of the build target. MSVC and ICC will detect 
incompatible PCHs and warn the user, GCC 3.4+ will do that if you 
specify -Winvalid-pch.


Other than that, it's a simple matter of adding defining the mechanisms 
per-compiler for building the PCH and telling the compiler to use it.


For MSVC/ICC "/Yu'${${PROJECT}_PCH_NAME}'".

For GCC it's a little fiddlier, because it has to be either in the same 
folder as the header file or before it in the search path. Adding -I 
${CMAKE_BINARY_DIR} is sub-optimal because now every #include searches 
an extra directory.


Scenario 2 can be dealt with through the use of MSVC/ICCs /FI (force 
include) and gcc's -include option.


For scenario #3 there are two options. a/ For every source file, create 
a sourcename.pch.${SOURCE_SUFFIX} file, which contains


#include <${${PROJECT}_PCH_NAME}>
#include "${${PROJECT}$_SOURCE_DIR}/${SOURCE_FILE}"

CMake could do this fairly simply by using something like CONFIGURE_FILE.

The other would be to define a macro that the user could put in every 
source file that #includes the PCH, and not actually pre-compile the 
header file.


(If the compiler supports forced inclusion, you could use that, but I'm 
not aware of any compiler that supports forced includes without also 
supporting PCH).


Implementing a "one size fits all" PCH solution is obviously not trivial 
work, and I understand the "roll your own" stance being taken. But CMake 
could move us a long way closer to making that practical /and/ solve 
some other problems in a single, fairly easy to implement step that also 
tackles issues with wrapper systems like tolua/swig/ecpg (postgres' 
embedded sql in c):


   add_generated_source(

TARGET 
SOURCE 
[COMPILE_FLAGS [APPEND] ]
[EXCLUDE_FLAGS] 
[CUSTOM_COMMAND  ]
[DEPENDS ...]
[WORKING_DIRECTORY ]
[PRE_BUILD | PRE_LINK]
   )

Variables defined inside:
   ${SOURCE} The source file name (to reduce the need for duplication)
   ${SOURCE_NO_SUFFIX} The source file name minus the final suffix
   ${SOURCE_SUFFIX} The suffix of the source file
   ${OUTPUT} The name of the output file (allowing filepath to be 
"something/${SOURCE_NO_SUFFIX}.${TARGET}.${SOURCE_SUFFIX}")

   ${OUTPUT_NO_SUFFIX}
   ${OUTPUT_SUFFIX}
   ${TARGET} The name of the target I'm being applied to

This doesn't eliminate the "roll your own" PCH solution entirely, but it 
gives a much clearer way of describing how to do it for the majority of 
cases (people trying to cross-support the "Big 4" of MSVC/ICC/XCode/GNU).


Example usage with the "precompiled header" part marked bold:

   # Call user-defined macro to find tolua++, figure out which database to use, 
etc.
   find_packages()

   # Add pre-compiled header support
   IF ( MSVC )

   *add_generated_source(
${Project_SOURCE_DIR}/includes/stdafx.h
TARGET ALL
SOURCE ${Project_SOURCE_DIR}/includes/stdafx.h
COMPILE_FLAGS "/Yc${SOURCE}"
EXCLUDE_FLAGS "/Yu${SOURCE}"
PRE_BUILD
)
   *
   ELSE IF ( COMPILER_IS_GNU )

   * add_generated_source(
${Project_SOURCE_DIR}/includes/stadafx.gch
TARGET ALL
SOURCE ${Project_SOURCE_DIR}/includes/stdafx.h
COMPILE_FLAGS "-o ${OUTPUT}"
EXCLUDE_FLAGS "-include ${SOURCE}"
PRE_BUILD
)*

   ELSE ( COMPILER_IS_GNU )

MESSAGE(FATAL_ERROR "Only works for MSVC/GNU")

   ENDIF ( MSVC OR COMPILER_IS_GNU )

   # Build a per-target lua wrapper.
   # i.e. build "src/luaWrapper.XXX.cc" from "etc/luaWrapper.XXX.pkg".
   # Always gets generated and then compiled just before the link step.
   add_generated_source(
${Project_SOURCE_DIR}/src/luaWrapper.${TARGET}.cc
TARGET ALL
SOURCE ${Project_SOURCE_DIR}/etc/${SOURCE_NO_SUFFIX}.${TARGET}.pkg
CUSTOM_COMMAND ${TOULAPP_EXECUTABLE} -n ${TARGET} -o ${OUTPUT} ${SOURCE}
*PRE_LINK
   *)


   # Library automatically gets src/luaWrapper.common.cc added to its 
compilation,
   # Also automatically builds and then includes the precompiled header with 
PROJ_LIBRARY defined.
   add_library(common
${Project_SOURCE_DIR}/src/common.cpp
${Project_SOURCE_DIR}/src/lua.cpp
   )
   set_property(TARGET common PROPERTY COMPILE_DEFINITIONS PROJ_LIBRARY)


   # Client automatically gets src/luaWrapper.client.cc added and the 
precompiled

[CMake] Single-shot compilation

2010-02-16 Thread Oliver Smith

On systems that support it, I'm wanting to do the equivalent of:

   $(CC) -pipe source1.cpp source2.cpp source3.cpp -fwhole-program

I can't figure out how to tell CMake to pass multiple sources to the 
compiler at once.


(Using versions 2.6 and 2.8)

- Oliver

___
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