My c++ program needs a folder path and I like to input from cmake configuration. For example, my c++ program is
int main(){
std::string pretrained_binary_proto("/home/Softwares/Libraries/caffe-master/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel");
}
I like to set this folder path using cmake.
/home/Softwares/Libraries/caffe-master/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
In my CMakeLists.txt, I have
set(CAFFE_MODEL_PATH "/home/nyan/Softwares/Libraries/caffe-master/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel")
But I don't see that CAFFE_MODEL_PATH in my ccmake.. configuration. Then how can I include that path to my program?
The "easy" way:
add_definitions(-DCAFFE_MODEL_PATH=\"${CAFFE_MODEL_PATH}\")
and then use CAFFE_MODEL_PATH constant in the code.
More preferred way if you have many such defines:
yourproject-config.h.cmake with contents like #cmakedefine CAFFE_MODEL_PATH.configure_file(yourproject-config.h.cmake yourproject-config.h)include_directories(${CMAKE_CURRENT_BINARY_DIR})#include "yourproject-config.h" whenever and wherever you need to access your constants.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With