Hello,
I am trying to cross compile a cmake project with static library but getting error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
MATH_LIBRARY
linked by target "final" in directory /home/hela/openwrt-sdk-19.07.7-x86-64_gcc-7.5.0_musl.Linux-x86_64/build_dir/target-x86_64_musl/my_math
this is the package structure:
/my_math$ tree
.
├── Makefile
└── src
├── CMakeLists.txt
├── include
│ └── my_math.h
├── lib
│ └── libmy_math.a
└── main.cpp
here is the cmake file:
cmake_minimum_required(VERSION 2.8.9)
project (my_math)
add_executable(final main.cpp)
INSTALL(TARGETS final RUNTIME DESTINATION /usr/bin/)
find_library(MATH_LIBRARY my_math HINTS ${PROJECT_SOURCE_DIR}/lib)
include_directories(${PROJECT_SOURCE_DIR}/include)
target_link_libraries(final LINK_PUBLIC pthread ${MATH_LIBRARY})
and this is the makefile:
##############################################
# OpenWrt Makefile for My math
##############################################
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=my_math
PKG_VERSION:=3.0.1
PKG_RELEASE:=1
CMAKE_INSTALL:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
CMAKE_OPTIONS += \
-L$(PKG_BUILD_DIR)/src/lib \
-I$(PKG_BUILD_DIR)/src/include
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/my_math
SECTION:=utils
CATEGORY:=Utilities
TITLE:=shared -- shared library
DEPENDS:=+libstdcpp
endef
define Package/my_math/description
shared library checking.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Configure
$(call Build/Configure/Default, --with-linux-headers=$(LINUX_DIR))
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
$(TARGET_CONFIGURE_OPTS)
endef
define Package/my_math/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/final $(1)/bin/
endef
$(eval $(call BuildPackage,my_math))
Any suggestion what to change in makefile or cmake please?