I'm just starting out with cmake, and trying to set up a fairly simple project. Although the project itself is simple, it links to a number of static libraries which aren't built by cmake. They could be, I suppose - they are my libraries - but I need to sort out how to link to third party libraries anyway.
Here is what I have so far...
cmake_minimum_required(VERSION 2.8.1)
cmake_policy(VERSION 2.8.1)
project( test01 )
include_directories("../../cpplib/sh_core" "../../cpplib/sh_core2" "../../cpplib/sh_genlib")
link_directories("../../cpplib/_vc_debug")
add_library( sh_core STATIC IMPORTED )
add_library( sh_core2 STATIC IMPORTED )
add_library( sh_genlib STATIC IMPORTED )
add_executable( test01 test01 test01_ast test01_parse test01_scan test01_main )
target_link_libraries(test01 sh_core sh_core2 sh_genlib)
The problem is that the three libraries that I'm trying to link to aren't being referenced correctly in the generated project file. They are listed as sh_core-NOTFOUND
, sh_core2-NOTFOUND
and sh_genlib-NOTFOUND
.
I think perhaps I don't need the link_directories
from above, but I do need a find_library
command. But I've taken a quick look at that command in the docs and... WTF!!! I already have a headache, and I really can't cope with that mass of seemingly redundant complexity ATM. Besides, seeing this much complexity for something that should be perfectly simple suggests to me that I'm looking in the wrong place.
So... how do I tell cmake where to find those libraries?
Bonus question - how do I set this up so the generated project handles both a debug build and a release build? Note - the release versions of the imported libraries have the same filenames, but are in a "../../cpplib/_vc_release" folder.