我正在尝试使用cmke和gcc 5.4
使用activemq-cpp编译代码find_path(ACTIVEMQCPP_DIR NAMES cms/Config.h HINTS $ENV{ACTIVEMQDIR})
此处ACTIVEMQDIR是一个设置为
的环境变量/usr/local/include/activemq-cpp-3.10.0
message(STATUS ACTIVEMQCPP_DIR=${ACTIVEMQCPP_DIR})
include_directories(${ACTIVEMQCPP_DIR})
// include_directories(/usr/local/include/activemq-cpp-3.10.0) 如果我明确地硬编码路径,那就没问题......
cmake的输出:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 1=/usr/local/include/activemq-cpp-3.10.0
-- 2=/usr/local/lib
-- 3=/usr/local/include/activemq-cpp-3.10.0
-- 4=/usr/local/lib/libactivemq-cpp.so
-- Configuring done
-- Generating done
-- Build files have been written to
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/oem/ClionProjects/untitled/b2
问题是include_directories(${ACTIVEMQCPP_DIR})
不起作用。变量ACTIVEMQCPP_DIR
未设置
答案 0 :(得分:0)
像这样写
include_directories($ENV{ACTIVEMQCPP_DIR})
所以cmake knows it's an environemnt variable。