1
0

cmake.mk 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. cmake_bool = $(patsubst %,-D%:BOOL=$(if $($(1)),ON,OFF),$(2))
  2. PKG_INSTALL:=1
  3. ifneq ($(findstring c,$(LIBRECMC_VERBOSE)),)
  4. MAKE_FLAGS+=VERBOSE=1
  5. endif
  6. CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
  7. CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
  8. HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
  9. MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .)
  10. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  11. cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
  12. else
  13. cmake_tool=$(shell which $(1))
  14. endif
  15. ifeq ($(CONFIG_CCACHE),)
  16. CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC))
  17. CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX))
  18. CMAKE_C_COMPILER_ARG1:=
  19. CMAKE_CXX_COMPILER_ARG1:=
  20. else
  21. CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
  22. CMAKE_C_COMPILER:=$(CCACHE)
  23. CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
  24. CMAKE_CXX_COMPILER:=$(CCACHE)
  25. CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
  26. endif
  27. CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
  28. CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
  29. CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
  30. CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
  31. CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOSTPKG);$(STAGING_DIR_HOST)
  32. CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
  33. define Build/Configure/Default
  34. mkdir -p $(CMAKE_BINARY_DIR)
  35. (cd $(CMAKE_BINARY_DIR); \
  36. CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  37. CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
  38. LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
  39. cmake \
  40. -DCMAKE_SYSTEM_NAME=Linux \
  41. -DCMAKE_SYSTEM_VERSION=1 \
  42. -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
  43. -DCMAKE_BUILD_TYPE=Release \
  44. -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
  45. -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
  46. -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
  47. -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
  48. -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
  49. -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
  50. -DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \
  51. -DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
  52. -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
  53. -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
  54. -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
  55. -DCMAKE_AR="$(CMAKE_AR)" \
  56. -DCMAKE_NM="$(CMAKE_NM)" \
  57. -DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
  58. -DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \
  59. -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
  60. -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
  61. -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
  62. -DCMAKE_STRIP=: \
  63. -DCMAKE_INSTALL_PREFIX=/usr \
  64. -DDL_LIBRARY=$(STAGING_DIR) \
  65. -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
  66. -DCMAKE_SKIP_RPATH=TRUE \
  67. $(CMAKE_OPTIONS) \
  68. $(CMAKE_SOURCE_DIR) \
  69. )
  70. endef
  71. define Build/InstallDev/cmake
  72. $(INSTALL_DIR) $(1)
  73. $(CP) $(PKG_INSTALL_DIR)/* $(1)/
  74. endef
  75. Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))
  76. define Host/Configure/Default
  77. (cd $(HOST_BUILD_DIR); \
  78. CFLAGS="$(HOST_CFLAGS)" \
  79. CXXFLAGS="$(HOST_CFLAGS)" \
  80. LDFLAGS="$(HOST_LDFLAGS)" \
  81. cmake \
  82. -DCMAKE_BUILD_TYPE=Release \
  83. -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
  84. -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
  85. -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
  86. -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
  87. -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
  88. -DCMAKE_FIND_ROOT_PATH="$(CMAKE_HOST_FIND_ROOT_PATH)" \
  89. -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
  90. -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
  91. -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
  92. -DCMAKE_STRIP=: \
  93. -DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \
  94. -DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \
  95. -DCMAKE_SKIP_RPATH=TRUE \
  96. -DCMAKE_INSTALL_LIBDIR=lib \
  97. $(CMAKE_HOST_OPTIONS) \
  98. $(HOST_CMAKE_SOURCE_DIR) \
  99. )
  100. endef
  101. MAKE_FLAGS += \
  102. CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
  103. CMAKE_DISABLE_cmake_check_build_system=1