CMakeLists.txt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright (C) 2011, 2012 Google Inc.
  2. #
  3. # This file is part of YouCompleteMe.
  4. #
  5. # YouCompleteMe is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # YouCompleteMe is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
  17. # The interesting parts of Boost have been extracted using
  18. # the BCP tool:
  19. # http://www.boost.org/doc/libs/1_54_0/tools/bcp/doc/html/index.html
  20. #
  21. # See the top-level update_boost.sh script for details on how bcp is called to
  22. # generate BoostParts.
  23. cmake_minimum_required( VERSION 2.8 )
  24. project( BoostParts )
  25. set( Python_ADDITIONAL_VERSIONS 2.7 2.6 )
  26. find_package( PythonLibs 2.6 REQUIRED )
  27. if ( NOT PYTHONLIBS_VERSION_STRING VERSION_LESS "3.0.0" )
  28. message( FATAL_ERROR
  29. "CMake found python3 libs instead of python2 libs. YCM works only with "
  30. "python2.\n" )
  31. endif()
  32. file( GLOB_RECURSE SOURCES *.cpp )
  33. # We need to remove all the thread cpp files and then add them on a per-platform
  34. # basis
  35. file( GLOB_RECURSE to_remove libs/thread/*.cpp libs/detail/*.cpp )
  36. if( to_remove )
  37. list( REMOVE_ITEM SOURCES ${to_remove} )
  38. endif()
  39. set( COMMON_SOURCES
  40. libs/thread/src/future.cpp
  41. )
  42. set( WIN_SOURCES
  43. libs/thread/src/win32/thread.cpp
  44. libs/thread/src/win32/timeconv.inl
  45. libs/thread/src/win32/tss_dll.cpp
  46. libs/thread/src/win32/tss_pe.cpp
  47. )
  48. set( UNIX_SOURCES
  49. libs/thread/src/pthread/once.cpp
  50. libs/thread/src/pthread/thread.cpp
  51. libs/thread/src/pthread/timeconv.inl
  52. )
  53. list( APPEND SOURCES ${COMMON_SOURCES} )
  54. if ( WIN32 )
  55. list( APPEND SOURCES ${WIN_SOURCES} )
  56. else()
  57. list( APPEND SOURCES ${UNIX_SOURCES} )
  58. endif()
  59. #############################################################################
  60. include_directories(
  61. SYSTEM
  62. ${CMAKE_CURRENT_SOURCE_DIR}
  63. ${PYTHON_INCLUDE_DIRS}
  64. )
  65. add_library( BoostParts ${SOURCES} )
  66. #############################################################################
  67. if( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG )
  68. # No warnings. We just use Boost as is so warnings coming from it are just
  69. # noise.
  70. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
  71. endif()
  72. #############################################################################
  73. if( NOT WIN32 )
  74. # Linking fails without this on some platforms, notably anything x64.
  75. set_target_properties( BoostParts PROPERTIES COMPILE_FLAGS "-fPIC")
  76. endif()
  77. #############################################################################
  78. # Special compiler and linker flags for MSVC
  79. if( MSVC )
  80. set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
  81. set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" )
  82. endif()
  83. if( SYSTEM_IS_SUNOS )
  84. # SunOS needs this setting for thread support
  85. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthreads" )
  86. endif()