Hello,

our project, which is currently using scons is structured like this

ROOT
  - SConstruct
  - CMakeLists.txt
  - src/
    - SConscript
    - CMAkeLists.txt
    - Module1
      - somesourcefiles.cpp
      - tests/
        - testsourcefiles.cpp
      - config/
         - configsourcefile.cpp
     - Module2 (like Module1)
     - ...

Right now the SConstruct calls SConscript

sourcesModule1 = [
    Glob('Module1/*.cpp'),
    Glob('Module2/config/*.cpp')
]

The test files (Boost Test) are compiled to a standalone executable

sourcesTests = [
    Glob('*/tests/*.cpp'),
    File("testing/main.cpp")
]

We currently have 4 targets. A static and dynamic lib (comprised of all 
modules), a binary (comprised of all modules +
main.cpp) and the test binary (all modules, tests and test main.cpp).

I was able to replicate that structure with CMake and it builds fine:


src/CMakeLists.txt:

file(GLOB sourcesAllNoMain
  "Module1/*.cpp"
  "Module1/config/*.cpp")

file(GLOB sourcesTests
  "*/tests/*.cpp")

set (sourcesAllNoMain ${sourcesAllNoMain} PARENT_SCOPE)
set (sourcesTests ${sourcesTests} PARENT_SCOPE)


ROOT/CMakeLists.txt:

add_subdirectory("src")

add_library(solib ${sourcesAllNoMain})
set_target_properties(solib
  PROPERTIES OUTPUT_NAME libprecice)
target_link_libraries(solib ${PYTHON_LIBRARIES})
target_link_libraries(solib ${MPI_LIBRARIES})
target_link_libraries(solib ${Boost_LIBRARIES})
target_link_libraries(solib ${petsc})


Now, in the docs I everywhere read not to add the files using GLOB. However, I 
have found no definitive guide how to add
project files in a large project with subdirs like that.

How would you do it in cmakeish fashion?

I know this might be a FAQ, but googled for days and found no suitable answer.

Thanks a lot,
Florian
-- 

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

Reply via email to