当BOOST_INCLUDEDIR和BOOST_LIBRARYDIR不同时,find_package(Boost)错误

时间:2019-04-17 07:54:02

标签: boost cmake

我正在尝试将Boost编译为共享库,并使它们成为我的跨平台 CMake项目的依赖项。

为此,我为win32,x64和linux编译了boost,它们的boost文件夹结构如下:

- boost_1_69_0/
  - boost/
  - stage/
    - win32
      - lib
    - x64
      - lib
    - linux
      - lib

然后我在做

set(BOOST_INCLUDEDIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/boost_1_69_0)
set(BOOST_LIBRARYDIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/boost_1_69_0/stage/win32)
find_package(Boost REQUIRED COMPONENTS filesystem)

并得到:

CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.

Boost version: 1.69.0

Boost include path: C:/bla/SW/cmake-template/external/boost_1_69_0

Could not find the following Boost libraries:

        boost_filesystem

那是个错误吗?


如果我将lib文件夹从win32内部移到其父目录,即:

- boost_1_69_0/
  - boost/
  - stage/
    - lib

这是boost的b2构建东西的默认方式,然后一切正常。但是后来我无法为不同的平台使用不同的boost二进制文件。


编辑

使用set(Boost_DEBUG ON),我发现我的项目是在使用v140的情况下使用Visual Studio v141工具集编译的,因此FindBoost在寻找boost_filesystem-vc140-mt-x64-1_69而不是boost_filesystem-vc140-mt-x64-1_69

我想问题已经转移到找到一种方法来强制搜索v141或(更好)使用--layout=system,并找到一种方法使其强制寻找boost_filesystem。有办法吗?

1 个答案:

答案 0 :(得分:1)

这里的问题是CMake搜索与特定命名方案匹配的boost库。您的库与此不同,因为文件名中编码了一些选项。您有两种选择:

  1. 再次编译boost,但是这次运行module FSM_TB; reg clk,left, right, reset; wire LA,LB,LC,RA,RB,RC; FSM dut(clk, reset, left, right, LA, LB, LC, RA, RB, RC); //apply inputs initial begin reset = 0; left = 1; right = 0; #30; reset = 1;#30; end //generate clock always begin clk = 0; #5; clk = 1; #5; end endmodule 可执行文件时带有module FSM( input clk, input reset, input left, input right, output LA, output LB, output LC, output RA, output RB, output RC ); reg[2:0] state = 3'b000; reg [2:0] nextstate; reg r ; parameter S0 = 3'b000; parameter S1 = 3'b100; parameter S2 = 3'b110; parameter S3 = 3'b111; //state register always @ (posedge clk, posedge reset) if(reset) begin state <= S0; r = 0; end else begin // if !reset if(left) r = 0; if(right) r = 1; state <= nextstate; end //next state logic always @ (*) case(state) S0: if(left^right) //if left xor right is 1, state is going to change nextstate = S1; else nextstate = S0; S1: nextstate = S2; S2: nextstate = S3; S3: nextstate = S0; default: nextstate = S0; endcase //output logic assign LC = (r== 0) & (state==S3); assign LB = (r== 0) & ((state==S3)|(state == S2)); assign LA = (r== 0) & ((state==S3)|(state == S2)|(state == S1)); assign RC = (r == 1) &(state==S3); assign RB = (r == 1) &((state==S3)|(state == S2)); assign RA = (r == 1) &((state==S3)|(state == S2)|(state == S1)); endmodule 标志。这将创建具有标准名称(如pandasimport pandas as pd cars=pd.read_csv("./cars.csv") prices=pd.read_csv("./price.csv") ### iterate over the price changes as rows for i,row in prices.iterrows(): ### find where cars["tittle2"]==row["ori_price1"] # and update column ['tittle2'] to row["new_price2"] cars.loc[cars["tittle2"]==row["ori_price1"], ['tittle2']] = row["new_price2"] cars.to_csv("cars_updated.csv",index=False) 之类的库文件。
  2. 使用以下variables dedicated to boost variants给CMake一些有关如何命名库文件的提示(由于我没有像您这样的等效系统,所以这些都是猜测,您可能必须采用):
    • .grid { display: grid; grid-template-columns: 100px 400px; grid-gap: 10px; }
    • <div class="grid"> <label>File Name:</label> <input type="text" size="30" name="Filename" value="<%=files%>" readonly> <label>URL Link:</label> <input type="url" size="100" name="URL Link" value="<%=url%>" readonly> <label>Start Date:</label> <input class="txtStartDate" type="date" id="txtStartDate" name="Start Date" value="<%=currentDate%>" readonly> <label>End Date:</label> <input class="txtEndDate" type="date" id="txtEndDate" name="txtEndDate" value="<%=defaultDate%>" readonly required/> <label>Enable:</label> <div> <input id="on" class="mandatory" type="radio" name="radioEnableStatus" value="1" checked/> <label for="on">On</label> <input id="off" class="mandatory" type="radio" name="radioEnableStatus" value="0" /> <label for="off">Off</label> </div> </div>