[CMake] Re: CMake Digest, Vol 39, Issue 38

cjacker jzhuang at redflag-linux.com
Thu Jul 19 01:59:22 EDT 2007


Shall I reply this message?
I found a question about "redflag"

"Is RedFlag's project using CMake?"

Yes.

I am A so called "Development Dept. Senior Manager" from RedFlag.

From Akademy 2006 in dublin(I was there), I know more about cmake.

When we were preparing for next release of RF, I request every buddy in RF use cmake as project management tool.

All project we developed ourselves will use cmake.

I already make a internal presentation about the benefit of cmake and how to use cmake.

Also, I am writing a tutorail in Chinese about cmake. It is open and free. but not too short, just like a free book(up to now, more than 10000 Chinese Characters.)

I hope more peoples in China can known cmake and use cmake to manage his project.

I already released the finished chapters in Some Chinese linux Forum, hope more peoples can join it and make the tutorial better.

Because I am also a newbie, there is still a lot of questions, I will try to find the answer myself.

If I can not find it, I hope we can get help from this maillist.


Thanks.


cmake-request at cmake.org 写道:
> Send CMake mailing list submissions to
> 	cmake at cmake.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.cmake.org/mailman/listinfo/cmake
> or, via email, send a message with subject or body 'help' to
> 	cmake-request at cmake.org
>
> You can reach the person managing the list at
> 	cmake-owner at cmake.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of CMake digest..."
>
>
> Today's Topics:
>
>    1. Re: CMake precompiled header support (in MSVC 7.1)
>       (Alexandru Ciobanu)
>    2. Re: CMake precompiled header support (in MSVC 7.1) (Dave Wolfe)
>    3. Re: rc compile options in visual studio (Jon W)
>    4. About variable Usage in cmake (cjacker)
>    5. Re: About variable Usage in cmake (Clark J. Wang)
>    6. how to use CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH? (cjacker)
>    7. Re: how to use CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH?
>       (Alan W. Irwin)
>    8. Re: how to use CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH?
>       (Clark J. Wang)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 18 Jul 2007 12:10:08 -0400
> From: Alexandru Ciobanu <aciobanu at matrox.com>
> Subject: Re: [CMake] CMake precompiled header support (in MSVC 7.1)
> To: Alexander Jasper <alexander.jasper at gmx.net>
> Cc: cmake at cmake.org
> Message-ID: <469E3B60.5070204 at matrox.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hi, Alexander!
>
> I've been able to implement Precompiled Headers for a project. We use 
> the Intel compiler on Linux, but still, the steps are the same:
>    - compile a stdafx.cpp with /Yc ( gives the .pch file )
>    - compile the normal source files using /Yu
>
> Here is a rough sketch of a possible solution:
>
>     # in ${src} you have all the source files
>
>     if ( ${PCH} STREQUAL "ON" )
>
>         # here you build the pch ( force it as a static lib )
>         add_compile_flags ( stdafx.cpp "/Ycstdafx.pch" )
>         add_library ( pch_stdafx STATIC stdafx.cpp )
>
>         foreach ( i ${src} )
>             add_compile_flags ( ${i} "/Yustdafx.pch" )
>         endforeach ( i ${src} )
>
>     endif ( ${PCH} STREQUAL "ON" )
>
>     # here you add your lib/exe
>     add_libraray ( yourLIB SHARED ${src} )
>
>     if ( ${PCH} STREQUAL "ON" )
>        add_dependencies ( yourLIB pch_stdafx )
>     endif ( ${PCH} STREQUAL "ON" )
>
>
> NOTE: add_compile_flags () is macro to append compile flags to files unlike
> set_source_files_properties() which overwrites them.
>
> Since CMake does not have an add_object() command in order to use it for 
> building
> stdafx.cpp, I have used something like add_libraray ( pch_target STATIC 
> stdafx.cpp )
> to do it. You will get the extra lib (libpch_stdafx.a), but you'll also 
> get the .pch file.
>
> Setting pch_stdafx as dependency to yourLIB is important. *This* is what
> makes your .pch file be created *before* the sources are compiled.
>
> Please also note that I did this for Intel C++ compiler.  I hope you can
> implement this in MSVC as well.
>
> Alex Ciobanu
>
>
>
>
> Alexander Jasper wrote:
>   
>> Hi all,
>>
>> First of all I like say thank you to the Cmake community for providing this great build tool free of charge. 
>>
>> After using it for some while now we are facing problems with the build times. Therefore we think using pre-compiled headers in MSVC 7.1. As CMake doesn’t seem to have "native" support precompiled headers we added the corresponding options to the compiler options by at appropriate Cmake command. Apart from being platform depdent this also has the drawback that MSVC does honor the build ordr that is required when sing PCH. When using PCH “through a file” (usually stdafx.h in MSVC projects) you have a corresponding .ccp file building the precompiled headers while being build itself. Hence, this .ccp has to be the first being built for each project. MSVC takes care of that if indicate what PCH to use in the project settings. But what we are doing is to provide the corresponding options to the compiler directly. The MSVC in this does take care of building the PCH first. This results in an error.
>>
>> Does anybody know a solution here or have a suggestion or hint?
>> W/o PCH support building large projects is very time consuming, so I‘m sure there must be solution or were I missing something the manual? Surprisingly  I did not find much information regarding that on the web.
>>
>> Thanks in advance.
>>
>> Kind regards
>>
>> Alexander
>>   
>>     
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 18 Jul 2007 12:23:18 -0400
> From: "Dave Wolfe" <dwolfe at gforcetech.com>
> Subject: [CMake] Re: CMake precompiled header support (in MSVC 7.1)
> To: cmake at cmake.org
> Message-ID: <WorldClient-F200707181223.AA23180388 at gforcetech.com>
> Content-Type: text/plain; charset=us-ascii
>
> It looks like this was fixed in CMake 2.4.7(?), which was just posted.
> See: http://www.cmake.org/Bug/bug.php?op=show&bugid=3512
>
> Upgrading should fix your problem.  Please reply if it still does not
> work for you...
>
> HTH,
>
> - Dave Wolfe
>   gForce Technologies, Inc.
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 18 Jul 2007 11:49:56 -0600
> From: "Jon W" <knowdat at gmail.com>
> Subject: [CMake] Re: rc compile options in visual studio
> To: cmake at cmake.org
> Message-ID:
> 	<de3ecc1d0707181049q1d4e30c1rc0e58d5ff1167813 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 7/17/07, Jon W <knowdat at gmail.com> wrote:
>   
>> When using visual studio, the resource compile options are updated
>> with the cxx preprocessor definitions and the cxx include paths.
>>
>> How can I remove all of the cxx preprocessor/include definitions and
>> redefine the options?  I haven't had any luck trying to reset the
>> options such as:
>>
>> set(CMAKE_RC_FLAGS "" CACHE STRING "Resetting" FORCE)
>> set(CMAKE_RC_SOURCE_FILE_EXTENSIONS "rc rc2" CACHE STRING "Resetting" FORCE)
>> set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <CMAKE_RC_FLAGS>
>> /fo<OBJECT> <SOURCE>" CACHE STRING "Resetting the rc options." FORCE)
>>     
>
> Is it possible to reset the rc compiler options?  This is currently
> stopping me from being able to compile, as the .cpp files need one set
> of include paths, and the rc files need another.  When the include
> paths are combined the .cpp files compile with errors, so I really
> need to be able to specify separate options and include paths.
>
> Thank you,
> Jon
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 19 Jul 2007 10:56:08 +0800
> From: cjacker <jzhuang at redflag-linux.com>
> Subject: [CMake] About variable Usage in cmake
> To: cmake at cmake.org
> Message-ID: <469ED2C8.7080204 at redflag-linux.com>
> Content-Type: text/plain; charset=GB2312
>
> I am writing a not too short Chinese tutorial about cmake.
> Up to now nine chapter had already been finished, include:
>
> prefix
> 1,about cmake
> 2,how to install cmake.
>
> 3,Hello World in cmake
> use helloworld as a demo to illustrate how to use cmake to manage and
> build a project.
> introduce PROJECT ADD_EXECUTABLE command and
> <projectname>_SOURCE_DIR,<projectname>_BINARY_DIR.
> also introduce in-source build and out-of-source build.
>
> 4,make Hello World better
> add more things to Helloworld, document, scripts, and illustrate the
> syntax of INSTALL and how to use it.
>
> 5,Manage shared library and static library
> introduce ADD_LIBRARY SET_TARGET_PROPERTIES command.
> also include how to build same name shared and static library and shared
> library versioning.
>
> 6,Use libraries in your project
> introduce INCLUDE_DIRECTORIES LINK_DIRECTORIES and TARGET_LINK_LIBRARIES
> command.
>
> 7,pre-defined cmake variables
> a lot of varibles in cmake, like CMAKE_BINARY_DIR and so on.
>
> 8,cmake command
> all commands in cmake.
>
> 9,how to use Find_ modules and write you own modules.
> also include CMAKE_MODULE_PATH varible.
>
>
>
>
> when I use cmake, the variable usage is confused me.
> for example, commonly if we want to use a variable, we should use ${},
> for example:
>
> MESSAGE(STATUS "the dir is: ${PROJECT_SOURCE_DIR}")
>
> SET(SRC_LIST main.c t1.c)
> ADD_EXECUTABLE(hello ${SRC_LIST})
>
> but when we use IF ELSEIF ENDIF command.
>
> we had to use it like
>
> FIND_PACKAGE(libX X11 /usr/lib/xorg)
> IF(libX) or IF(NOT libX)
>
> I can not use it like IF(${libX}) or IF(NOT ${libX}).
>
> anybody can explain the rule that how to use variable in cmake?
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 19 Jul 2007 11:22:02 +0800
> From: "Clark J. Wang" <dearvoid at gmail.com>
> Subject: Re: [CMake] About variable Usage in cmake
> To: "CMake Mailing List" <cmake at cmake.org>
> Message-ID:
> 	<a96f63770707182022h78db082co581fd1a8ad2fe290 at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On 7/19/07, cjacker <jzhuang at redflag-linux.com> wrote:
>   
>> I am writing a not too short Chinese tutorial about cmake.
>> Up to now nine chapter had already been finished, include:
>>     
>
>
> Interesting. Is RedFlag's project using CMake? :-)
>
> prefix
>   
>> 1,about cmake
>> 2,how to install cmake.
>>
>> 3,Hello World in cmake
>> use helloworld as a demo to illustrate how to use cmake to manage and
>> build a project.
>> introduce PROJECT ADD_EXECUTABLE command and
>> <projectname>_SOURCE_DIR,<projectname>_BINARY_DIR.
>> also introduce in-source build and out-of-source build.
>>
>> 4,make Hello World better
>> add more things to Helloworld, document, scripts, and illustrate the
>> syntax of INSTALL and how to use it.
>>
>> 5,Manage shared library and static library
>> introduce ADD_LIBRARY SET_TARGET_PROPERTIES command.
>> also include how to build same name shared and static library and shared
>> library versioning.
>>
>> 6,Use libraries in your project
>> introduce INCLUDE_DIRECTORIES LINK_DIRECTORIES and TARGET_LINK_LIBRARIES
>> command.
>>
>> 7,pre-defined cmake variables
>> a lot of varibles in cmake, like CMAKE_BINARY_DIR and so on.
>>
>> 8,cmake command
>> all commands in cmake.
>>
>> 9,how to use Find_ modules and write you own modules.
>> also include CMAKE_MODULE_PATH varible.
>>
>>
>>
>>
>> when I use cmake, the variable usage is confused me.
>> for example, commonly if we want to use a variable, we should use ${},
>> for example:
>>
>> MESSAGE(STATUS "the dir is: ${PROJECT_SOURCE_DIR}")
>>
>> SET(SRC_LIST main.c t1.c)
>> ADD_EXECUTABLE(hello ${SRC_LIST})
>>
>> but when we use IF ELSEIF ENDIF command.
>>
>> we had to use it like
>>
>> FIND_PACKAGE(libX X11 /usr/lib/xorg)
>> IF(libX) or IF(NOT libX)
>>
>> I can not use it like IF(${libX}) or IF(NOT ${libX}).
>>     
>
>
> The `IF(var)' or `IF(NOT var)' command expects `var' to be the name of a
> variable. This is stated in CMake's manual. So, for your situation
> `IF(${libX})' is the same as `IF(/usr/lib/xorg)' and then CMake will check
> the value of the variable named `/usr/lib/xorg'.
>
> anybody can explain the rule that how to use variable in cmake?
>   
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>>     
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://public.kitware.com/pipermail/cmake/attachments/20070719/63a8474d/attachment.htm
>
> ------------------------------
>
> Message: 6
> Date: Thu, 19 Jul 2007 11:22:26 +0800
> From: cjacker <jzhuang at redflag-linux.com>
> Subject: [CMake] how to use CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH?
> To: cmake at cmake.org
> Message-ID: <469ED8F2.5090208 at redflag-linux.com>
> Content-Type: text/plain; charset=GB2312
>
> cmake-2.4.6.
>
> I had search it anywhere.
> somebody said these are environment variable
> in some CMakeLists.txt
> I also find something like this:
> set(CMAKE_INCLUDE_PATH /include)
> This seems like a cmake variable not a environment variable.
>
> Also, I did not find this variable in kdebase of KDE4.
>
> Anyboy can help to explain how to use CMAKE_INCLUDE_PATH?
>
> I search the CMAKE Sourcecode, it seems only useful in FIND_PATH command.
>
> but how to use it?
>
> I do it in bash like this:
> export CMAKE_INCLUDE_PATH=/usr/include/hello
>
> FIND_PATH(myPath hello.h ${CMAKE_INCLUDE_PATH})
>
> it just did not works.
>
> if we use it like $ENV{CMAKE_INCLUDE_PATH}, it is a normal environment
> variable.
>
> We can define anyname like this.
>
>
> also, if we must explicitly use this variable in CMakeLists.txt, how can
> we handle things like --extra-include-dir?
>
> I already search the maillist of cmake, please do not redirect me to
> other post here. It did not works.
>
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 18 Jul 2007 20:39:31 -0700 (PDT)
> From: "Alan W. Irwin" <irwin at beluga.phys.uvic.ca>
> Subject: Re: [CMake] how to use CMAKE_INCLUDE_PATH and
> 	CMAKE_LIBRARY_PATH?
> To: cjacker <jzhuang at redflag-linux.com>
> Cc: cmake at cmake.org
> Message-ID: <Pine.LNX.4.60.0707182031340.4545 at puvpxnqrr.zlyna.ubzr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On 2007-07-19 11:22+0800 cjacker wrote:
>
>   
>> I do it in bash like this:
>> export CMAKE_INCLUDE_PATH=/usr/include/hello
>>
>> FIND_PATH(myPath hello.h ${CMAKE_INCLUDE_PATH})
>>     
>
> Try this instead:
>
> export CMAKE_INCLUDE_PATH=/usr/include/hello
>
> then in CMake script:
>
> FIND_PATH(myPath hello.h)
>
> In other words, drop the ${CMAKE_INCLUDE_PATH} from FIND_PATH and all should
> be well.
>
> How the CMAKE_INCLUDE_PATH environment variable or equivalent CMake variable
> is used is documented at http://cmake.org/HTML/Documentation.html.  That's
> where you find most explicit documentation (or the equivalent "cmake
> --help-full" command.  For a summary of useful CMake variables look at
> http://www.cmake.org/Wiki/CMake_Useful_Variables.
>
> HTH
>
> Alan
> __________________________
> Alan W. Irwin
>
> Astronomical research affiliation with Department of Physics and Astronomy,
> University of Victoria (astrowww.phys.uvic.ca).
>
> Programming affiliations with the FreeEOS equation-of-state implementation
> for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
> package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
> Linux Links project (loll.sf.net); and the Linux Brochure Project
> (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________
>
>
> ------------------------------
>
> Message: 8
> Date: Thu, 19 Jul 2007 11:40:45 +0800
> From: "Clark J. Wang" <dearvoid at gmail.com>
> Subject: Re: [CMake] how to use CMAKE_INCLUDE_PATH and
> 	CMAKE_LIBRARY_PATH?
> To: "CMake Mailing List" <cmake at cmake.org>
> Message-ID:
> 	<a96f63770707182040v2a5307a9wa9e4fea5f9bd05e5 at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On 7/19/07, cjacker <jzhuang at redflag-linux.com> wrote:
>   
>> cmake-2.4.6.
>>
>> I had search it anywhere.
>> somebody said these are environment variable
>> in some CMakeLists.txt
>> I also find something like this:
>> set(CMAKE_INCLUDE_PATH /include)
>> This seems like a cmake variable not a environment variable.
>>
>> Also, I did not find this variable in kdebase of KDE4.
>>
>> Anyboy can help to explain how to use CMAKE_INCLUDE_PATH?
>>     
>
>
> According to CMake's manual this var is used by FIND_PATH and FIND_FILE.
>
> I search the CMAKE Sourcecode, it seems only useful in FIND_PATH command.
>   
>> but how to use it?
>>
>> I do it in bash like this:
>> export CMAKE_INCLUDE_PATH=/usr/include/hello
>>
>> FIND_PATH(myPath hello.h ${CMAKE_INCLUDE_PATH})
>>
>> it just did not works.
>>     
>
>
> It works fine for me. And the paths defined in CMAKE_INCLUDE_PATH are
> searched by default so you needn't pass it to FIND_PATH explicitly.
>
> if we use it like $ENV{CMAKE_INCLUDE_PATH}, it is a normal environment
>   
>> variable.
>>     
>
>
> By default FIND_PATH use both CMake var CMAKE_INCLUDE_PATH and the env var
> CMAKE_INCLUDE_PATH to search files.
>
> We can define anyname like this.
>   
>> also, if we must explicitly use this variable in CMakeLists.txt, how can
>> we handle things like --extra-include-dir?
>>
>> I already search the maillist of cmake, please do not redirect me to
>> other post here. It did not works.
>>
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>>     
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://public.kitware.com/pipermail/cmake/attachments/20070719/ee8229ec/attachment.html
>
> ------------------------------
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
> End of CMake Digest, Vol 39, Issue 38
> *************************************
>
>
>   




More information about the CMake mailing list