On 2013-03-01 13:58, Atgeirr Rasmussen wrote:
I made a dir with only softlinks to the five needed modules and the
following CMakeLists.txt:

>   ADD_SUBDIRECTORY(opm-core)
  ADD_SUBDIRECTORY(opm-polymer)

It failed, the output is in this gist:

The main problem here (there are several, I'm taking notes...) is that all of the projects have for instance a "doc" target, as Markus commented.

He also hints on a solution: (ab)using external projects. You can for instance have a CMakeLists.txt like the attached in the parent directory.

(Please excuse the gobblelygock at the end to setup things; this should preferrably be in a module. Perhaps it could even read dune.module for the dependencies)

This will build all the modules (in order) in one go. Unfortunately, it will run the configure process anew for each project also.

I'll look more into the add_subdirectory option later.

--
        Roland.
cmake_minimum_required(VERSION 2.8)
project (OPM NONE)
include (ExternalProject)

# these should be in topological order
set (PROJECTS
  "opm-core"
  "dune-cornerpoint DEPENDS opm-core"
  "opm-porsol DEPENDS opm-core dune-cornerpoint"
  "opm-upscaling DEPENDS opm-core dune-cornerpoint opm-porsol"
  )

# recreate all variables on the command-line
get_cmake_property(CACHE_VARS CACHE_VARIABLES)
foreach(v IN LISTS CACHE_VARS)
  if (NOT (("${v}" STREQUAL "CMAKE_PROJECT_NAME") OR
                ("${v}" STREQUAL "CMAKE_HOME_DIRECTORY")))
        list (APPEND vars
          "-D${v}=${${v}}"
          )
  endif (NOT (("${v}" STREQUAL "CMAKE_PROJECT_NAME") OR
                ("${v}" STREQUAL "CMAKE_HOME_DIRECTORY")))
endforeach (v)
  
set (args)
foreach (p IN LISTS PROJECTS)
  # split string into name and dependencies
  string (REPLACE "DEPENDS" ";" p ${p})
  list (GET p 0 name)
  list (REMOVE_AT p 0)
  string (STRIP "${name}" name)
  string (STRIP "${p}" p)
  string (REPLACE " " ";" p "${p}")

  # create an external project using the name as a sub-directory
  externalproject_add (${name}
        PREFIX ${name}
        SOURCE_DIR ${PROJECT_SOURCE_DIR}/${name}
        BINARY_DIR ${PROJECT_BINARY_DIR}/${name}
        CMAKE_ARGS ${vars} ${args}
        INSTALL_COMMAND ""
        DEPENDS ${p}
        )

  # now that we've "build" it, add it to the arguments
  list (APPEND args
        -D${name}_DIR:PATH=${PROJECT_BINARY_DIR}/${name}
        )
endforeach (p)
_______________________________________________
Opm mailing list
[email protected]
http://www.opm-project.org/mailman/listinfo/opm

Reply via email to