CMakeLists.txt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # Copyright (c) 2016-present, Facebook, Inc.
  3. # All rights reserved.
  4. #
  5. # This source code is licensed under the BSD-style license found in the
  6. # LICENSE file in the root directory of this source tree. An additional grant
  7. # of patent rights can be found in the PATENTS file in the same directory.
  8. #
  9. cmake_minimum_required(VERSION 2.8.9)
  10. project(fasttext)
  11. # The version number.
  12. set (fasttext_VERSION_MAJOR 0)
  13. set (fasttext_VERSION_MINOR 1)
  14. include_directories(fasttext)
  15. set(CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3 -march=native")
  16. set(HEADER_FILES
  17. src/args.h
  18. src/dictionary.h
  19. src/fasttext.h
  20. src/matrix.h
  21. src/model.h
  22. src/productquantizer.h
  23. src/qmatrix.h
  24. src/real.h
  25. src/utils.h
  26. src/vector.h)
  27. set(SOURCE_FILES
  28. src/args.cc
  29. src/dictionary.cc
  30. src/fasttext.cc
  31. src/main.cc
  32. src/matrix.cc
  33. src/model.cc
  34. src/productquantizer.cc
  35. src/qmatrix.cc
  36. src/utils.cc
  37. src/vector.cc)
  38. add_library(fasttext-shared SHARED ${SOURCE_FILES} ${HEADER_FILES})
  39. add_library(fasttext-static STATIC ${SOURCE_FILES} ${HEADER_FILES})
  40. add_library(fasttext-static_pic STATIC ${SOURCE_FILES} ${HEADER_FILES})
  41. set_target_properties(fasttext-shared PROPERTIES OUTPUT_NAME fasttext)
  42. set_target_properties(fasttext-static PROPERTIES OUTPUT_NAME fasttext)
  43. set_target_properties(fasttext-static_pic PROPERTIES OUTPUT_NAME fasttext_pic
  44. POSITION_INDEPENDENT_CODE True)
  45. add_executable(fasttext-bin src/main.cc)
  46. target_link_libraries(fasttext-bin pthread fasttext-static)
  47. set_target_properties(fasttext-bin PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME fasttext)
  48. install (TARGETS fasttext-shared
  49. LIBRARY DESTINATION lib)
  50. install (TARGETS fasttext-static
  51. ARCHIVE DESTINATION lib)
  52. install (TARGETS fasttext-static_pic
  53. ARCHIVE DESTINATION lib)
  54. install (TARGETS fasttext-bin
  55. RUNTIME DESTINATION bin
  56. PUBLIC_HEADER DESTINATION include/fasttext)