cmake.mk 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. PKG_INSTALL:=1
  2. ifneq ($(findstring c,$(LIBRECMC_VERBOSE)),)
  3. MAKE_FLAGS+=VERBOSE=1
  4. endif
  5. CMAKE_SOURCE_DIR:=.
  6. ifeq ($(CONFIG_CCACHE),)
  7. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  8. CMAKE_C_COMPILER:=$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)
  9. CMAKE_C_COMPILER_ARG1:=
  10. CMAKE_CXX_COMPILER:=$(TOOLCHAIN_DIR)/bin/$(TARGET_CXX)
  11. CMAKE_CXX_COMPILER_ARG1:=
  12. else
  13. CMAKE_C_COMPILER:=$(shell which $(TARGET_CC))
  14. CMAKE_C_COMPILER_ARG1:=
  15. CMAKE_CXX_COMPILER:=$(shell which $(TARGET_CXX))
  16. CMAKE_CXX_COMPILER_ARG1:=
  17. endif
  18. else
  19. CCACHE:=$(shell which ccache)
  20. ifeq ($(CCACHE),)
  21. CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
  22. endif
  23. CMAKE_C_COMPILER:=$(CCACHE)
  24. CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
  25. CMAKE_CXX_COMPILER:=$(CCACHE)
  26. CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
  27. endif
  28. define Build/Configure/Default
  29. (cd $(PKG_BUILD_DIR); \
  30. CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  31. CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  32. LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
  33. cmake \
  34. -DCMAKE_SYSTEM_NAME=Linux \
  35. -DCMAKE_SYSTEM_VERSION=1 \
  36. -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
  37. -DCMAKE_BUILD_TYPE=Release \
  38. -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
  39. -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
  40. -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
  41. -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
  42. -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
  43. -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
  44. -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
  45. -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
  46. -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
  47. -DCMAKE_FIND_ROOT_PATH="$(STAGING_DIR);$(TOOLCHAIN_DIR)" \
  48. -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
  49. -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
  50. -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
  51. -DCMAKE_STRIP=: \
  52. -DCMAKE_INSTALL_PREFIX=/usr \
  53. -DDL_LIBRARY=$(STAGING_DIR) \
  54. -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
  55. $(CMAKE_OPTIONS) \
  56. $(CMAKE_SOURCE_DIR) \
  57. )
  58. endef
  59. define Build/InstallDev/cmake
  60. $(INSTALL_DIR) $(1)
  61. $(CP) $(PKG_INSTALL_DIR)/* $(1)/
  62. endef
  63. Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))