# CMake project cross-compiling Error: variables set to NOTFOUND

**URL:** <https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101>\
**Category:** Code\
**Created:** [September 16, 2021, 1:54pm UTC](https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101 "2021-09-16T13:54:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hela](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hela](https://discourse.cmake.org/u/hela)\
**Post date:** [September 16, 2021, 1:54pm UTC](https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101/1 "2021-09-16T13:54:47Z")

</div>

Hello,  
I am trying to cross compile a cmake project with static library but getting error:

```auto
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:

```auto
/my_math$ tree
.
├── Makefile
└── src
    ├── CMakeLists.txt
    ├── include
    │ └── my_math.h
    ├── lib
    │ └── libmy_math.a
    └── main.cpp

```

here is the cmake file:

```auto
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:

```auto
##############################################
# 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?

---

<div class="post-metadata">

**Author:** ![hela](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hela](https://discourse.cmake.org/u/hela)\
**Post date:** [September 21, 2021, 1:23pm UTC](https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101/2 "2021-09-21T13:23:22Z")

</div>

Any suggestion for this issue please?
