[LEDE-DEV] [PATCH procd] cmake: Fix upgraded CMakeLists.txt

Florian Fainelli f.fainelli at gmail.com
Tue Sep 27 14:23:39 PDT 2016


Fix several things with this CMakeLists.txt file:

* add missing header search for ubox/uloop.h

* append the linker flags, do not override them (since they could contain path
  to the stating directory)

* remove link explicit against libgcc_pic

Verified this still produces a static binary as expected.

Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
---
 upgraded/CMakeLists.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/upgraded/CMakeLists.txt b/upgraded/CMakeLists.txt
index 093dba2f2f92..fc016f4c4ca3 100644
--- a/upgraded/CMakeLists.txt
+++ b/upgraded/CMakeLists.txt
@@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 2.6)
 
 PROJECT(upgraded C)
 ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
-set(CMAKE_EXE_LINKER_FLAGS "-static -fPIC")
+
+FIND_PATH(ubox_include_dir libubox/uloop.h)
+INCLUDE_DIRECTORIES(${ubox_include_dir})
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -fPIC")
 set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
 set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
 set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
@@ -11,7 +15,7 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
 set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
 ADD_EXECUTABLE(upgraded upgraded.c ../watchdog.c)
-TARGET_LINK_LIBRARIES(upgraded ubox rt -lc -lgcc_pic)
+TARGET_LINK_LIBRARIES(upgraded ubox rt -lc)
 INSTALL(TARGETS upgraded
 	RUNTIME DESTINATION sbin
 )
-- 
2.9.3




More information about the Lede-dev mailing list