From eed5f067f0e6b50aa2460a7cd56af9bdb774435f Mon Sep 17 00:00:00 2001 From: kanschat Date: Tue, 27 Aug 2013 13:43:50 +0000 Subject: [PATCH] add library targets git-svn-id: https://svn.dealii.org/trunk@30503 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/development/cmakelists.html | 69 ++++++++++++++++++++----- deal.II/doc/screen.css | 10 ++++ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/deal.II/doc/development/cmakelists.html b/deal.II/doc/development/cmakelists.html index e3adffb1f0..0714db239e 100644 --- a/deal.II/doc/development/cmakelists.html +++ b/deal.II/doc/development/cmakelists.html @@ -23,6 +23,7 @@
  • Simple CMakeLists.txt
  • Autopilot style CMakeLists.txt
  • Advanced CMakeLists.txt @@ -61,19 +62,19 @@

    Simple CMakeLists.txt

    - For larger projects the simple CMakeLists.txt presented - above tends to be too inflexible. So, if you wish to have more - control about targets the DEAL_II_SETUP_TARGET macro - might be of interest for you. Here is a full example - (plain text version): + In this section, we start out with a + minimal CMakeLists.txt based on + the DEAL_II_SETUP_TARGET macro. This method gives + full control of what's happening and is easily extensible to + more complex projects, as exemplified in the subsections here an + later in the section on advanced + topics. Here is a full example + (plain text + version): TODO: Fix plain text after finalizing! - TODO: Do some nicer formatting of pre. Here and possibly - globally. Do not use indentation by hand for this. - -

    +
     CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
     
     FIND_PACKAGE(deal.II 8.0 REQUIRED
    @@ -93,7 +94,7 @@ DEAL_II_SETUP_TARGET(mycode)
         

    Adding multiple executable targets

    In order to specify multiple executable targets, simply repeat the last two lines of the simple CMakeLists.txt:

    -
    +
     ADD_EXECUTABLE(mycode2 mycode2.cc)
     DEAL_II_SETUP_TARGET(mycode2)
     
    @@ -105,6 +106,46 @@ If the list gets longer, consider using
     a loop, possibly
     with GLOB.
     
    +    
    +    

    Adding libraries and common source files

    + +

    + Adding a library is as simple as adding an executable target. We + specify the library name and then have to tell cmake that the + executables depend on it. The code in the simple file below the + project definition accordingly changes for instance to: +

    + +
    +ADD_LIBRARY(mylib libsrc1.cc libsrc2.cc libsrc3.cc)
    +
    +ADD_EXECUTABLE(mycode mycode.cc)
    +DEAL_II_SETUP_TARGET(mycode)
    +TARGET_LINK_LIBRARIES(mycode mylib)
    +
    + +

    When you have multiple targets, +repeat the last line of code for each of them. Accordingly, +a loop becomes even more +attractive.

    + +

    If you only have a single file or few files with common source +code, an alternative to creating a library might be the option:

    + +
    +ADD_EXECUTABLE(mycode mycode.cc common.cc)
    +DEAL_II_SETUP_TARGET(mycode)
    +
    +ADD_EXECUTABLE(mycode2 mycode2.cc common.cc)
    +DEAL_II_SETUP_TARGET(mycode2)
    +
    + +

    You should be aware though that common.cc will be +compiled for each target, not only once.

    + +TODO: Matthias, is this correct? + +

    Adding a "run" target

    @@ -114,7 +155,7 @@ with GLOB. can only run a single executable):

    -
    +
     ADD_CUSTOM_TARGET(run COMMAND mycode
       COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration")
     
    @@ -134,7 +175,7 @@ ADD_CUSTOM_TARGET(run COMMAND mycode projects:

    -
    +
     FIND_PACKAGE(deal.II 8.0 REQUIRED
       HINTS
         ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
    @@ -209,7 +250,7 @@ $ cmake .
           variables before DEAL_II_INVOKE_AUTOPILOT() is called
           (plain text version):
     
    -
    +
     # (Optional)
     # Specify a list of files (file globs) that will be removed
     # with the "make runclean" and "make distclean" targets.
    diff --git a/deal.II/doc/screen.css b/deal.II/doc/screen.css
    index 5ca7aa3459..dd6605493a 100644
    --- a/deal.II/doc/screen.css
    +++ b/deal.II/doc/screen.css
    @@ -180,6 +180,16 @@ pre {
     	line-height: 1.1em;
     }
     	
    +pre.cmake {
    +	padding: 1em;
    +	text-align: left;
    +	text-indent: 0;
    +	border: 1px solid #d06fab;
    +	color: Black;
    +	background-color: #f9f9f9;
    +	line-height: 1.1em;
    +}
    +	
     pre.sample {
     	padding: 1em;
     	text-align: left;
    -- 
    2.39.5