CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
  2. project(LSDTopoTools)
  3. # Dependencies
  4. # ============
  5. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "findFFTW")
  6. find_package(PkgConfig REQUIRED)
  7. pkg_search_module(FFTW REQUIRED fftw3 IMPORTED_TARGET)
  8. include_directories(PkgConfig::FFTW)
  9. link_libraries (PkgConfig::FFTW)
  10. set(CMAKE_CXX_STANDARD 11)
  11. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  12. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -O3 -std=c++11")
  13. # We test if the open cv library is found.
  14. # If not we compile without lsdtt-valley-width program
  15. # OpenCV
  16. find_package(OpenCV)
  17. if(OpenCV_FOUND)
  18. message("I found OpenCV and am compiling the floodplain code")
  19. include_directories( ${OpenCV_INCLUDE_DIRS})
  20. # Build
  21. # =====
  22. set(LIB_HEADERS
  23. LSDBasin.hpp
  24. LSDChiTools.hpp
  25. LSDChiNetwork.hpp
  26. LSDChannel.hpp
  27. LSDCosmoData.hpp
  28. LSDCosmoRaster.hpp
  29. LSDCRNParameters.hpp
  30. LSDFlowInfo.hpp
  31. LSDIndexChannel.hpp
  32. LSDIndexChannelTree.hpp
  33. LSDIndexRaster.hpp
  34. LSDJunctionNetwork.hpp
  35. LSDMostLikelyPartitionsFinder.hpp
  36. LSDParameterParser.hpp
  37. LSDParticle.hpp
  38. LSDParticleColumn.hpp
  39. LSDRaster.hpp
  40. LSDRasterAggregator.hpp
  41. LSDRasterInfo.hpp
  42. LSDRasterMaker.hpp
  43. LSDRasterSpectral.hpp
  44. LSDSoilHydroRaster.hpp
  45. LSDStatsTools.hpp
  46. LSDShapeTools.hpp
  47. LSDSpatialCSVReader.hpp
  48. LSDStrahlerLinks.hpp
  49. LSDFloodplain.hpp
  50. LSDTerrace.hpp
  51. )
  52. string(REGEX REPLACE "([^;]+).hpp" "\\1.cpp" LIB_SOURCES "${LIB_HEADERS}")
  53. set(EXE_SOURCES
  54. lsdtt-drivers/lsdtt-basic-metrics.cpp
  55. lsdtt-drivers/lsdtt-channel-extraction.cpp
  56. lsdtt-drivers/lsdtt-chi-mapping.cpp
  57. lsdtt-drivers/lsdtt-cosmo-tool.cpp
  58. lsdtt-drivers/lsdtt-hillslope-channel-coupling.cpp
  59. lsdtt-drivers/lsdtt-valley-metrics.cpp
  60. )
  61. set(EXE_FILES)
  62. add_library(${PROJECT_NAME} ${LIB_SOURCES} ${LIB_HEADERS} )
  63. foreach(src_file ${EXE_SOURCES})
  64. string(REGEX REPLACE "([^;]+)/([^;]+).cpp" "\\2" exe_file ${src_file})
  65. list(APPEND EXE_FILES ${exe_file})
  66. add_executable(${exe_file} ${src_file})
  67. target_link_libraries(${exe_file} ${PROJECT_NAME} PkgConfig::FFTW)
  68. target_link_libraries(${exe_file} ${PROJECT_NAME} ${OpenCV_LIBS} )
  69. endforeach(src_file ${EXE_SOURCES})
  70. # Install
  71. # =======
  72. include(GNUInstallDirs)
  73. include(CMakePackageConfigHelpers)
  74. install(
  75. TARGETS ${EXE_FILES} ${PROJECT_NAME}
  76. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  77. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  78. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  79. )
  80. else()
  81. message("I am compiling without the openCV library")
  82. set(LIB_HEADERS
  83. LSDBasin.hpp
  84. LSDChiTools.hpp
  85. LSDChiNetwork.hpp
  86. LSDChannel.hpp
  87. LSDCosmoData.hpp
  88. LSDCosmoRaster.hpp
  89. LSDCRNParameters.hpp
  90. LSDFlowInfo.hpp
  91. LSDIndexChannel.hpp
  92. LSDIndexChannelTree.hpp
  93. LSDIndexRaster.hpp
  94. LSDJunctionNetwork.hpp
  95. LSDMostLikelyPartitionsFinder.hpp
  96. LSDParameterParser.hpp
  97. LSDParticle.hpp
  98. LSDParticleColumn.hpp
  99. LSDRaster.hpp
  100. LSDRasterAggregator.hpp
  101. LSDRasterInfo.hpp
  102. LSDRasterMaker.hpp
  103. LSDRasterSpectral.hpp
  104. LSDSoilHydroRaster.hpp
  105. LSDStatsTools.hpp
  106. LSDShapeTools.hpp
  107. LSDSpatialCSVReader.hpp
  108. LSDStrahlerLinks.hpp
  109. )
  110. string(REGEX REPLACE "([^;]+).hpp" "\\1.cpp" LIB_SOURCES "${LIB_HEADERS}")
  111. set(EXE_SOURCES
  112. lsdtt-drivers/lsdtt-basic-metrics.cpp
  113. lsdtt-drivers/lsdtt-channel-extraction.cpp
  114. lsdtt-drivers/lsdtt-chi-mapping.cpp
  115. lsdtt-drivers/lsdtt-cosmo-tool.cpp
  116. lsdtt-drivers/lsdtt-hillslope-channel-coupling.cpp
  117. )
  118. set(EXE_FILES)
  119. add_library(${PROJECT_NAME} ${LIB_SOURCES} ${LIB_HEADERS} )
  120. foreach(src_file ${EXE_SOURCES})
  121. string(REGEX REPLACE "([^;]+)/([^;]+).cpp" "\\2" exe_file ${src_file})
  122. list(APPEND EXE_FILES ${exe_file})
  123. add_executable(${exe_file} ${src_file})
  124. target_link_libraries(${exe_file} ${PROJECT_NAME} PkgConfig::FFTW)
  125. endforeach(src_file ${EXE_SOURCES})
  126. # Install
  127. # =======
  128. include(GNUInstallDirs)
  129. include(CMakePackageConfigHelpers)
  130. install(
  131. TARGETS ${EXE_FILES} ${PROJECT_NAME}
  132. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  133. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  134. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  135. )
  136. endif()