2017-07-18 853 views
0

我转换生成文件到的CMakeLists.txt在GitHub的项目 “https://github.com/Golevka/deformation-transfer” 例如,在文件夹/ corres_resolve 其生成文件是像以下。cmake的外部静态库循环依赖

{

INCLUDE_PATH := ./ ../external/include/ ../common/ 
SOURCE_PATH  := ./ ../common/ 
DEPENDENCY_PATH := dep 
OBJECT_PATH  := obj 

EXTERNAL_LIBS := $(wildcard ../external/lib/*.a) 
LDLIBS := -lm -lpthread 

CFLAGS += -O3 

include ../makefile.mk 

}

其makefile.mk是 {

vpath %.h $(INCLUDE_PATH) 
vpath %.c $(SOURCE_PATH) 
vpath %.d $(DEPENDENCY_PATH) 
vpath %.o $(OBJECT_PATH) 


## default .o and .dep path and program name 
OBJECT_PATH  ?= obj 
DEPENDENCY_PATH ?= dep 
PROGRAM_NAME ?= run 

# source trunk 
source-files = $(wildcard $(addsuffix /*.c, $(SOURCE_PATH))) 
source-list  = $(notdir $(source-files)) 

# binary trunk 
objname-list = $(subst .c,.o, $(source-list)) 
object-list  = $(addprefix $(OBJECT_PATH)/, $(objname-list)) 

# dependency trunk 
depname-list = $(subst .c,.d, $(source-list)) 
dependency-list = $(addprefix $(DEPENDENCY_PATH)/, $(depname-list)) 

# -I option to help the compiler finding the headers 
CFLAGS += $(addprefix -I, $(INCLUDE_PATH)) 

# Build external library cmdline parameter, those -Xlinker directives instructs 
# the linker find the correct linking sequence regardless the order of items 
# specified in EXTERNAL_LIBS.`enter code here` 
LOADLIBES += \ 
-Xlinker --start-group \ 
    $(addprefix -Xlinker , $(EXTERNAL_LIBS)) \ 
-Xlinker --end-group 

# PROGRAM_NAME is provided in custom makefile 
$(PROGRAM_NAME): $(object-list) 
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o [email protected] 
$(OBJECT_PATH)/%.o: %.c 
@mkdir -p $(OBJECT_PATH) 
$(COMPILE.c) $(OUTPUT_OPTION) $< 
# Resolve [object,source] -- [header] dependency 
-include $(dependency-list) 
$(DEPENDENCY_PATH)/%.d: %.c 
@mkdir -p $(DEPENDENCY_PATH) 
@$(CC) -M $(CFLAGS) $< > [email protected]$$$$;   \ 
sed 's,\($*\)\.o[ :]*,\1.o [email protected] : ,g' < [email protected]$$$$ > [email protected]; \ 
rm -f [email protected]$$$$ 

} 

不幸的是,$(EXTERNAL_LIBS)具有有循环依赖于每个10个静态* .a文件其他。 任何人都知道如何在CMakeLists.txt中处理这个问题?

回答

1

它显示在makefile.mk如何解决与--start-group--end-group链接器选项。

与海湾合作委员会,你可以使用-Wl, - 启动组和轮候册, - 端基左右(只)在target_link_libraries()

的问题库