1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
### example CMakeLists.txt to develop programs using OpenMS
project("Main")
cmake_minimum_required(VERSION 2.6)
## list all your executables here (a corresponding .C file should exist, e.g. Main.C)
set(my_executables
Main
)
## list all classes here, which are required by your executables
## (all these classes will be linked into a library)
set(my_sources
ExampleLibraryFile.C
)
## find OpenMS configuration and register target "OpenMS" (our library)
find_package(OpenMS)
## if the above fails you can try:
#find_package(OpenMS PATHS "</c/path/to/OpenMS>/cmake")
# check whether the OpenMS package was found
if (OpenMS_FOUND)
## include directories for OpenMS headers (and contrib)
include_directories(${OPENMS_INCLUDE_DIRS})
## append precompiler macros and compiler flags specific to OpenMS
## Warning: this could be harmful to your project. Check this if problems occur.
## Also, use this to add your own compiler flags, e.g. for OpenMP support.
## e.g. for Visual Studio use /openmp
## set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENMS_ADDCXX_FLAGS} /openmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENMS_ADDCXX_FLAGS}")
add_definitions(${OPENMS_DEFINITIONS})
## library with additional classes from above
add_library(my_custom_lib STATIC ${my_sources})
## add targets for the executables
foreach(i ${my_executables})
add_executable(${i} ${i}.C)
## link executables against OpenMS
target_link_libraries(${i} OpenMS my_custom_lib)
endforeach(i)
else(OpenMS_FOUND)
message(FATAL_ERROR "OpenMSConfig.cmake file not found!")
endif(OpenMS_FOUND)
|