> On May 3, 2017, at 8:20 PM, Sean Wayland <seanwayl...@gmail.com> wrote:
> 
> Hi all,
> 
> I am very new to cmake and boost. Sorry if my question is basic thanks for 
> your help in advance. 
> 
> I am having trouble linking a project to boost. I am using OSX 10.12.1 
> I am using clion 2017.1.1 
> 
> I installed boost on my machine using /bootstrap.sh --prefix=/usr/local/boost 
> --with-libraries=filesystem,system
> 
> I also tried a brew install boost also . 
> 
> Boost can indeed be found here usr/local/boost/ on my machine. 
> 
> I haven't had much luck getting boost to link properly. 
> 
> I believe the project uses the filesystem and tuple modules. 
> 
> I am getting this error 
> 
> CMake Error at CMakeLists.txt:557 (ADD_EXECUTABLE):
>   Cannot find source file:
> 
>     anyExecutable.cpp
> 


This error means that it can’t find the named source file. The path is relative 
to the CMakeLists.txt file in which you define the target. Does that source 
file exist in that location? 


> From what I have read I think that if you are using OSX that you have to use 
> the FIND_PACKAGE command to link things properly. I suspect that the code 
> below doesn't work because I need to properly place the exact filesystem 
> location of the executable file created in the add_executable command. 
> On a positive note I did get this message 
> -- Boost version: 1.63.0
> -- Found the following Boost libraries:
> --   program_options
> -- Configuring done
> 

This indicates that it found some version of boost, but it seems only the 
program_options library. I would add message(“$Boost_LIBRARIES”) after your 
find_package() statement to print out the location of the found libraries to 
see if that matches your expectation. I generally prefer to do a full staged 
build of boost from source..that typically looks like “./bootstrap.sh && ./b2 
stage” — and I then I point to that staged build using a BOOST_ROOT environment 
variable (the CMake boost finder will honor BOOST_ROOT, I believe). You can 
also just do a ./b2 install to put everything in /usr/local/. 

> I have tried various versions of these 2 cmakelists scripts below (A) and (B) 
>  
> 
> Can anyone point me in the direction of a solution here? 
> 
> 
> A) 
> 
> FIND_PACKAGE( Boost 1.63.0 COMPONENTS program_options REQUIRED )
> INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
> 
> ADD_EXECUTABLE( anyExecutable anyExecutable.cpp )
> 
> TARGET_LINK_LIBRARIES( anyExecutable ${Boost_LIBRARIES} )
> B) 
> INCLUDE_DIRECTORIES(usr/local/boost/include/)
> 
> ADD_EXECUTABLE(  anyExecutable myMain.cpp )
> 
> TARGET_LINK_LIBRARIES( anyExecutable usr/local/boost/lib/ )
> 
> 

version (A) seems closer to what you want to me - but I suspect the error you 
posted was from option (B). Perhaps try running A again and share the error 
message(s) you get with that.

-Mike


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to