CMakeLists.txt 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. cmake_minimum_required(VERSION 2.8)
  17. PROJECT(lib2)
  18. if (APPLE)
  19. set(DYLIBS ${BOOST_REGEX_LIBRARIES})
  20. list(APPEND DYLIBS ${ICU_LIBRARIES})
  21. list(APPEND DYLIBS ${XALAN_LIBRARIES})
  22. list(APPEND DYLIBS ${XERCES_LIBRARIES})
  23. list(APPEND DYLIBS ${BINUTILS_LIBRARIES})
  24. elseif (WIN32)
  25. #TODO: Should find these dlls not assume them.
  26. if (NOT USE_NATIVE_LIBRARIES)
  27. find_file (BOOST_REGEX_BIN "boost_regex-vc90-mt-1_44.dll" "${EXTERNALS_DIRECTORY}/boost/windows-i386-vc90/lib" NO_DEFAULT_PATH)
  28. endif (NOT USE_NATIVE_LIBRARIES)
  29. find_file (ICU_DT_BIN "icudt36.dll" "${EXTERNALS_DIRECTORY}/icu/bin" NO_DEFAULT_PATH)
  30. find_file (ICU_IN_BIN "icuin36.dll" "${EXTERNALS_DIRECTORY}/icu/bin" NO_DEFAULT_PATH)
  31. find_file (ICU_UC_BIN "icuuc36.dll" "${EXTERNALS_DIRECTORY}/icu/bin" NO_DEFAULT_PATH)
  32. find_file (OPENSSL_LIB_BIN "libeay32.dll" "${EXTERNALS_DIRECTORY}/openssl/win32/lib" NO_DEFAULT_PATH)
  33. find_file (OPENSSL_SSL_BIN "ssleay32.dll" "${EXTERNALS_DIRECTORY}/openssl/win32/lib" NO_DEFAULT_PATH)
  34. find_file (XALAN_C_BIN "Xalan-C_1_10.dll" "${EXTERNALS_DIRECTORY}/xalan/xalan-c/bin" NO_DEFAULT_PATH)
  35. find_file (XALAN_MESSAGES_BIN "XalanMessages_1_10.dll" "${EXTERNALS_DIRECTORY}/xalan/xalan-c/bin" NO_DEFAULT_PATH)
  36. find_file (XERCES_C_BIN "xerces-c_2_7.dll" "${EXTERNALS_DIRECTORY}/xalan/xerces-c/bin" NO_DEFAULT_PATH)
  37. set(DYLIBS "")
  38. if (NOT USE_NATIVE_LIBRARIES)
  39. list(APPEND DYLIBS ${BOOST_REGEX_BIN})
  40. endif (NOT USE_NATIVE_LIBRARIES)
  41. list(APPEND DYLIBS ${ICU_DT_BIN} ${ICU_IN_BIN} ${ICU_UC_BIN})
  42. list(APPEND DYLIBS ${OPENSSL_LIB_BIN} ${OPENSSL_SSL_BIN})
  43. list(APPEND DYLIBS ${XALAN_C_BIN} ${XALAN_MESSAGES_BIN})
  44. list(APPEND DYLIBS ${XERCES_C_BIN})
  45. endif()
  46. foreach(dylib ${DYLIBS})
  47. get_filename_component(dylib_path ${dylib} REALPATH)
  48. if (WIN32)
  49. install(PROGRAMS "${dylib_path}" DESTINATION ${EXEC_DIR})
  50. elseif (APPLE)
  51. install(PROGRAMS "${dylib_path}" DESTINATION lib2)
  52. get_filename_component(dylib_name_ext ${dylib_path} NAME)
  53. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  54. #TODO: Should be able resolve alias's to alias's correctly?
  55. string(REPLACE ".2.21.dylib" ".2.dylib" dylib_2_path "${dylib_path}")
  56. if (NOT "${dylib_2_path}" STREQUAL "${dylib_path}")
  57. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_2_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  58. endif ()
  59. string(REPLACE ".28.0.dylib" ".28.dylib" dylib_28_path "${dylib_path}")
  60. if (NOT "${dylib_28_path}" STREQUAL "${dylib_path}")
  61. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_28_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  62. endif ()
  63. string(REPLACE ".48.1.dylib" ".48.dylib" dylib_48_path "${dylib_path}")
  64. if (NOT "${dylib_48_path}" STREQUAL "${dylib_path}")
  65. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_48_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  66. endif ()
  67. string(REPLACE ".51.2.dylib" ".51.dylib" dylib_51_path "${dylib_path}")
  68. if (NOT "${dylib_51_path}" STREQUAL "${dylib_path}")
  69. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_51_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  70. endif ()
  71. string(REPLACE ".110.0.dylib" ".dylib" dylib_110_path "${dylib_path}")
  72. if (NOT "${dylib_110_path}" STREQUAL "${dylib_path}")
  73. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_110_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  74. endif ()
  75. string(REPLACE ".51.2.dylib" ".51.dylib" dylib_51_path "${dylib_path}")
  76. if (NOT "${dylib_51_path}" STREQUAL "${dylib_path}")
  77. set(fixupCommand "${fixupCommand}\r\nexecute_process(COMMAND install_name_tool -change \"${dylib_51_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" \${file})")
  78. endif ()
  79. install(CODE "
  80. file(GLOB files \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${EXEC_DIR}/*\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/*.dylib\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/plugins/*.dylib\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib2/*.dylib\")
  81. foreach(file \${files})
  82. ${fixupCommand}
  83. endforeach ()
  84. ")
  85. endif()
  86. endforeach(dylib)