Owl Positioning System: a Wi-Fi-based, infrastructure-centred indoor positioning system. http://owlps.pu-pm.univ-fcomte.fr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. # This file is part of the Owl Positioning System (OwlPS) project.
  2. # It is subject to the copyright notice and license terms in the
  3. # COPYRIGHT.t2t file found in the top-level directory of this
  4. # distribution and at
  5. # https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
  6. # No part of the OwlPS Project, including this file, may be copied,
  7. # modified, propagated, or distributed except according to the terms
  8. # contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
  9. # distributed along with this file, either separately or by replacing
  10. # this notice by the COPYRIGHT.t2t file's contents.
  11. cmake_minimum_required(VERSION 2.8)
  12. project(OwlPS)
  13. ### Build paths ###
  14. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  15. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  16. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  17. # Path for the generated header files
  18. set(GENERATED_INCLUDE "${PROJECT_BINARY_DIR}/include")
  19. include_directories("${GENERATED_INCLUDE}")
  20. ### Dependencies ###
  21. # Note: we test here the dependencies relevant for more than one module;
  22. # other tests are done in each module's directory.
  23. # Add cmake/Modules to the molude path so that CMake can find the
  24. # additional FindXXX modules we (unfortunately have to) ship
  25. set(CMAKE_MODULE_PATH
  26. ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
  27. # Check if we've got POSIX threads
  28. set(CMAKE_THREAD_PREFER_PTHREAD on)
  29. find_package(Threads)
  30. if (CMAKE_THREAD_LIBS_INIT AND CMAKE_USE_PTHREADS_INIT)
  31. set(HAVE_PTHREADS true)
  32. endif()
  33. # Check if we've got the Confuse library
  34. find_package(Confuse)
  35. # Check if Doxygen is available
  36. find_package(Doxygen)
  37. ### OwlPS' version ###
  38. # First, try to get it from the environment variable OWLPS_VERSION
  39. if (NOT "$ENV{OWLPS_VERSION}" STREQUAL "")
  40. add_definitions(-DOWLPS_VERSION="$ENV{OWLPS_VERSION}")
  41. # Environment variable OWLPS_VERSION not set: try to get the version
  42. # number from git describe
  43. else()
  44. execute_process(
  45. COMMAND git describe
  46. WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
  47. RESULT_VARIABLE RET
  48. OUTPUT_VARIABLE OWLPS_VERSION
  49. ERROR_QUIET
  50. OUTPUT_STRIP_TRAILING_WHITESPACE)
  51. if (${RET} EQUAL 0)
  52. add_definitions(-DOWLPS_VERSION="${OWLPS_VERSION}")
  53. else()
  54. add_definitions(-DOWLPS_VERSION="unknown version")
  55. endif()
  56. endif()
  57. ### Options ###
  58. # Configurations
  59. set(CMAKE_CONFIGURATION_TYPES
  60. Debug Release RelWithDebInfo MinSizeRel
  61. CACHE STRING "Set the configurations" FORCE)
  62. # Default configuration
  63. if (NOT CMAKE_BUILD_TYPE)
  64. set(CMAKE_BUILD_TYPE RelWithDebInfo
  65. CACHE STRING "Set the default configuration" FORCE)
  66. endif()
  67. ### Flags ###
  68. # Specific compiler flags
  69. # These variables are to be used (manually) when compiling a shared
  70. # library or an executable (or static library).
  71. set(SHARED_FLAGS "-fPIC")
  72. set(EXE_FLAGS "-fPIE")
  73. # Common compiler flags
  74. set(C_CXX_COMMON_FLAGS "-Wall -Wextra")
  75. set(C_FLAGS "${C_CXX_COMMON_FLAGS} -Wstrict-prototypes")
  76. set(CXX_FLAGS "${C_CXX_COMMON_FLAGS}")
  77. if (NOT CMAKE_C_FLAGS)
  78. set(CMAKE_C_FLAGS ${C_FLAGS}
  79. CACHE STRING "Set default C flags" FORCE)
  80. endif()
  81. if (NOT CMAKE_CXX_FLAGS)
  82. set(CMAKE_CXX_FLAGS ${CXX_FLAGS}
  83. CACHE STRING "Set default C++ flags" FORCE)
  84. endif()
  85. # Linker flags
  86. # Question: why the hell does CMAKE_SHARED_LINKER_FLAGS contain " "
  87. # by default?!
  88. if ("${CMAKE_SHARED_LINKER_FLAGS}" STREQUAL " ")
  89. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined"
  90. CACHE STRING "Set default shared linker flags" FORCE)
  91. endif()
  92. # Linker flags when linking an executable
  93. # Note: -fpie prevents from building static executables, therefore it
  94. # has been deactivated, but it would be nice to find a work-around
  95. # to allow building dynamic (and semistatic) targets with -pie and
  96. # static ones without.
  97. #if ("${CMAKE_EXE_LINKER_FLAGS}" STREQUAL " ")
  98. # set(CMAKE_EXE_LINKER_FLAGS "-pie -fPIE"
  99. # CACHE STRING "Set default shared linker flags" FORCE)
  100. #endif()
  101. ### Libraries targets ###
  102. add_subdirectory(libowlps)
  103. include_directories(libowlps)
  104. add_subdirectory(libowlps-client)
  105. include_directories(libowlps-client)
  106. add_subdirectory(libowlps-resultreader)
  107. include_directories(libowlps-resultreader)
  108. ### Programs targets ###
  109. ## Aggregator ##
  110. if (HAVE_PTHREADS AND CONFUSE_FOUND)
  111. add_subdirectory(owlps-aggregator)
  112. else() # Warn the user about missing dependencies
  113. if (NOT HAVE_PTHREADS)
  114. message(WARNING
  115. "OwlPS Aggregator dependency missing: POSIX threads")
  116. endif()
  117. if (NOT CONFUSE_FOUND)
  118. message(WARNING
  119. "OwlPS Aggregator dependency missing: libConfuse")
  120. endif()
  121. endif()
  122. ## Client ##
  123. add_subdirectory(owlps-client)
  124. ## Listener ##
  125. add_subdirectory(owlps-listener)
  126. ## Positioner ##
  127. # OwlPS Positioner can be built only with a minimal version of GCC, or
  128. # Clang++. CMAKE_CXX_COMPILER_VERSION is not guaranteed to be set, so we
  129. # will test the version number only if possible.
  130. set(POSITIONER_MIN_GCC_VERSION 4.7)
  131. set(POSITIONER_MIN_CLANG_VERSION 3.2)
  132. if (CMAKE_CXX_COMPILER_ID STREQUAL GNU) # Are we using GCC?
  133. # Test the compiler version if we can
  134. if (${CMAKE_CXX_COMPILER_VERSION} AND
  135. ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS ${POSITIONER_MIN_GCC_VERSION})
  136. # GCC's version is too low
  137. message(WARNING
  138. "OwlPS Positioner requires GCC (g++) >= ${POSITIONER_MIN_GCC_VERSION}")
  139. else()
  140. # GCC's version is OK or we couldn'd get it
  141. add_subdirectory(owlps-positioner)
  142. endif()
  143. elseif (CMAKE_CXX_COMPILER_ID STREQUAL Clang) # Are we using Clang?
  144. if (${CMAKE_CXX_COMPILER_VERSION} AND
  145. ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS ${POSITIONER_MIN_CLANG_VERSION})
  146. # Clang's version is too low
  147. message(WARNING
  148. "OwlPS Positioner requires GCC >= ${POSITIONER_MIN_GCC_VERSION}")
  149. else()
  150. # Clang's version is OK or we couldn'd get it
  151. add_subdirectory(owlps-positioner)
  152. endif()
  153. else() # we're not using GCC
  154. message(WARNING
  155. "OwlPS Positioner requires GCC (>= ${POSITIONER_MIN_GCC_VERSION}) or Clang (>= ${POSITIONER_MIN_CLANG_VERSION})")
  156. endif()
  157. ## UDP-to-HTTP ##
  158. if (HAVE_PTHREADS)
  159. add_subdirectory(owlps-udp-to-http)
  160. else() # Warn the user about missing dependencies
  161. message(WARNING
  162. "OwlPS UDP-to-HTTP dependency missing: POSIX threads")
  163. endif()
  164. ## Scripts ##
  165. add_subdirectory(scripts)
  166. ### Documentation ###
  167. add_subdirectory(doc)
  168. ### Meta-targets ###
  169. # The OWLPS_SEMISTATIC_TARGET is defined in subdirectories
  170. add_custom_target(semistatic DEPENDS ${OWLPS_SEMISTATIC_TARGETS})
  171. # The OWLPS_STATIC_TARGET is defined in subdirectories
  172. add_custom_target(static DEPENDS ${OWLPS_STATIC_TARGETS})
  173. ### Tests ###
  174. add_custom_target(tests
  175. COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_positioner
  176. DEPENDS test_positioner)