CMakeLists.txt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # RWD version for newsfsys with PVOC EX support
  2. cmake_minimum_required(VERSION 2.8.3)
  3. project (CDP)
  4. # ENABLE_TESTING()
  5. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  6. set(CMAKE_COMPILER_IS_CLANG 1)
  7. endif()
  8. message(STATUS "${CMAKE_HOME_DIRECTORY}")
  9. message(STATUS "installing to ${CMAKE_INSTALL_PREFIX}")
  10. set(CMAKE_CXX_FLAGS_RELEASE "-O3 -std=c++11 -stdlib=libc++")
  11. set(CMAKE_C_FLAGS_RELEASE "-O3 ")
  12. set(CMAKE_VERBOSE_MAKEFILE OFF)
  13. # Project definitions
  14. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/NewRelease")
  15. message(STATUS "building to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
  16. # Relative install paths
  17. set(EXECUTABLE_INSTALL_DIR "bin")
  18. function(my_install name)
  19. install(TARGETS ${name}
  20. RUNTIME DESTINATION "${EXECUTABLE_INSTALL_DIR}" )
  21. endfunction(my_install)
  22. set(LIBRARY_INSTALL_DIR "lib")
  23. message(STATUS "LIBRARY INSTALL DIR: ${LIBRARY_INSTALL_DIR}")
  24. include(TestBigEndian)
  25. include(CheckFunctionExists)
  26. include(CheckIncludeFile)
  27. include(CheckIncludeFileCXX)
  28. include(CheckLibraryExists)
  29. include(CMakeParseArguments)
  30. include(CheckCCompilerFlag)
  31. include(CheckCXXCompilerFlag)
  32. # If FAIL_MISSING is true and the dependencies are not fulfilled,
  33. # it will abort the cmake run.
  34. # If FAIL_MISSING is false, it will set the option to OFF.
  35. # If the target is not enabled, it will do nothing.
  36. # example: check_deps(BUILD_NEW_PARSER FLEX_EXECUTABLE BISON_EXECUTABLE)
  37. function(check_deps option)
  38. if(${option})
  39. set(i 1)
  40. while( ${i} LESS ${ARGC} )
  41. set(dep ${ARGV${i}})
  42. if(NOT ${dep})
  43. if(FAIL_MISSING)
  44. message(FATAL_ERROR
  45. "${option} is enabled, but ${dep}=\"${${dep}}\"")
  46. else()
  47. message(STATUS "${dep}=\"${${dep}}\", so disabling ${option}")
  48. set(${option} OFF PARENT_SCOPE)
  49. # Set it in the local scope too
  50. set(${option} OFF)
  51. endif()
  52. endif()
  53. math(EXPR i "${i}+1")
  54. endwhile()
  55. endif()
  56. if(${option})
  57. message(STATUS "${option} is enabled")
  58. else()
  59. message(STATUS "${option} is disabled")
  60. endif()
  61. endfunction(check_deps)
  62. ### COMPILER OPTIMIZATION FLAGS
  63. option(USE_COMPILER_OPTIMIZATIONS "Use the default CDP compiler optimization flags" ON)
  64. if(USE_COMPILER_OPTIMIZATIONS)
  65. include(cmake/CompilerOptimizations.cmake)
  66. endif()
  67. if(APPLE)
  68. set(OSX_VERSION " ")
  69. endif()
  70. # Include this after the install path definitions so we can override them here.
  71. # Also after function definitions so we can use them there
  72. find_file(CUSTOM_CMAKE "Custom.cmake" HINTS ${CMAKE_HOME_DIRECTORY})
  73. if(CUSTOM_CMAKE)
  74. message(STATUS "Including Custom.cmake file: ${CUSTOM_CMAKE}")
  75. include(${CUSTOM_CMAKE})
  76. else()
  77. message(STATUS "Not using Custom.cmake file.")
  78. endif()
  79. if(WIN32 AND NOT MSVC)
  80. if(EXISTS "C:/MinGW/include")
  81. include_directories(C:/MinGW/include)
  82. else()
  83. MESSAGE(STATUS "MinGW include dir not found")
  84. endif()
  85. set(CMAKE_MODULE_LINKER_FLAGS
  86. "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--add-stdcall-alias")
  87. endif()
  88. if(WIN32)
  89. set(CMAKE_SHARED_LIBRARY_PREFIX "")
  90. set(CMAKE_SHARED_MODULE_PREFIX "")
  91. set(EXTRA_LIBRARIES
  92. kernel32
  93. user32
  94. ole32
  95. winspool
  96. odbc32
  97. gdi32
  98. comdlg32
  99. advapi32
  100. shell32
  101. oleaut32
  102. uuid)
  103. else()
  104. set(EXTRA_LIBRARIES "m")
  105. endif(WIN32)
  106. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  107. set(LINUX YES)
  108. else()
  109. set(LINUX NO)
  110. endif()
  111. ## USER OPTIONS ##
  112. option(FAIL_MISSING "Fail when a required external dependency is not present (useful for packagers)" OFF)
  113. option(BUILD_RELEASE "Build for release" ON)
  114. # Optional targets, they should all default to ON (check_deps will disable them if not possible to build)
  115. ##
  116. set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
  117. check_c_compiler_flag(-fvisibility=hidden HAS_VISIBILITY_HIDDEN)
  118. check_cxx_compiler_flag(-fvisibility=hidden HAS_CXX_VISIBILITY_HIDDEN)
  119. if (HAS_VISIBILITY_HIDDEN)
  120. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
  121. endif()
  122. if (HAS_CXX_VISBILITY_HIDDEN)
  123. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
  124. endif()
  125. if(APPLE)
  126. if(BUILD_INSTALLER)
  127. set(CS_FRAMEWORK_DEST "${CMAKE_INSTALL_PREFIX}")
  128. endif()
  129. set(DEFAULT_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/)
  130. if(NOT CMAKE_OSX_SYSROOT AND EXISTS ${DEFAULT_OSX_SYSROOT})
  131. set(CMAKE_OSX_SYSROOT ${DEFAULT_OSX_SYSROOT})
  132. endif()
  133. if(EXISTS ${CMAKE_OSX_SYSROOT})
  134. set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
  135. endif()
  136. endif()
  137. set(CDPLIB "lib")
  138. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  139. add_definitions("-Wno-format")
  140. # add_compiler_flags("-g")
  141. endif()
  142. set(BUILD_BIN_DIR ${BUILD_DIR/bin})
  143. set(BUILD_LIB_DIR ${BUILD_DIR}/lib)
  144. message(STATUS "BUILD_BIN_DIR set to ${BUILD_BIN_DIR}")
  145. message(STATUS "BUILD_LIB_DIR set to ${BUILD_LIB_DIR}")
  146. # OS specific checks
  147. TEST_BIG_ENDIAN(BIG_ENDIAN)
  148. ## CONFIGURATION ##
  149. SET(BUILD_SHARED_LIBS OFF)
  150. ## HEADER/LIBRARY/OTHER CHECKS ##
  151. option(USE_LOCAL_PORTAUDIO "Build and use PA programs" ON)
  152. if(USE_LOCAL_PORTAUDIO)
  153. message(STATUS "paprogs to be built")
  154. else()
  155. message(STATUS "paprogs not built")
  156. endif()
  157. set(HEADERS_TO_CHECK
  158. unistd.h io.h fcntl.h stdint.h
  159. sys/time.h sys/types.h termios.h
  160. values.h winsock.h sys/socket.h
  161. dirent.h )
  162. foreach(header ${HEADERS_TO_CHECK})
  163. # Convert to uppercase and replace [./] with _
  164. string(TOUPPER ${header} tmp)
  165. string(REGEX REPLACE [./] "_" upper_header ${tmp})
  166. check_include_file(${header} HAVE_${upper_header})
  167. endforeach()
  168. ##set(LIBCDP_CFLAGS -D__BUILDING_LIBCDP)
  169. include_directories(./dev/include)
  170. #RWD for PVOCEX support
  171. include_directories(./dev/newinclude)
  172. #if(WIN32)
  173. include_directories(${PORTAUDIO_INCLUDE_DIRECTORY})
  174. #endif(WIN32)
  175. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  176. # Add the install target
  177. ###??
  178. set(LIBCDP_LIBS
  179. ${PORTAUDIO_LIBRARY})
  180. if(WIN32)
  181. list(APPEND LIBCDP_LIBS "${CDP_WINDOWS_LIBRARIES}")
  182. endif()
  183. if(LINUX)
  184. message(STATUS "Building on Linux")
  185. add_definitions( -Dunix -Dlinux -D_X86_ -DFILE_AMB_SUPPORT)
  186. list(APPEND LIBCDP_LIBS m)
  187. endif()
  188. if(APPLE)
  189. message(STATUS "Building on OSX")
  190. # we - CDP - need the macosx directive to distribute; not wanted for a personal build
  191. # e.g. -mmacosx-version-min=10.8
  192. add_definitions( -Dunix)
  193. list(APPEND LIBCDP_LIBS m)
  194. endif()
  195. if(WIN32)
  196. message(STATUS "Building on Windows")
  197. add_definitions(-DWIN32 -D_WIN32)
  198. endif()
  199. #add_compiler_flags(${LIBCDP_CFLAGS} TARGETS ${CDPLIB})
  200. add_subdirectory(dev)
  201. # # uninstall target
  202. # configure_file(
  203. # "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
  204. # "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  205. # IMMEDIATE @ONLY)
  206. # add_custom_target(uninstall
  207. # COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  208. ## target etags/tags
  209. if(UNIX)
  210. add_custom_target(tags COMMAND etags `find ${CMAKE_CURRENT_SOURCE_DIR} -name \\*.cc -or -name \\*.hh -or -name \\*.cpp -or -name \\*.h -or -name \\*.c | grep -v " " `)
  211. add_custom_target(etags DEPENDS tags)
  212. endif()
  213. # build a CPack driven installer package
  214. #include (InstallRequiredSystemLibraries)
  215. set (CPACK_PACKAGE_NAME "cdp")
  216. set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
  217. set (CPACK_PACKAGE_VERSION "8.0.1")
  218. set (CPACK_PACKAGE_VERSION_MAJOR "8")
  219. set (CPACK_PACKAGE_VERSION_MINOR "0")
  220. set (CPACK_PACKAGE_VERSION_PATCH "1")
  221. include (CPack)