[CMake] TARGET_LINK_LIBRARIES got a link error
Alexander Neundorf
a.neundorf-work at gmx.net
Fri Apr 12 15:34:24 EDT 2013
On Friday 12 April 2013, Lloyd wrote:
> Hi,
>
> I am new to Cmake and at present exploring its features for migrating our
> projects build system to use it.
>
> I have main source folder inside that another folder contains the source
> for our custom library.
>
> I understand that the problem is with my cmake file. Through that the
> generated project cannot locate the location of my library build location.
> What is the right way to solve this kind of problem?
>
> Thanks,
> Lloyd
>
> As a sample I am including my Cmake code
>
> #Cmake file of library source code
> #Path-> Myproject/src/lib/reverse
>
> cmake_minimum_required (VERSION 2.6)
>
> if(WIN32)
> SET (REV_SRC reverse.cpp reverse.h)
> else(WIN32)
> SET (REV_SRC reverse.cpp)
> endif(WIN32)
>
> ADD_DEFINITIONS(-DREVERSE_EXPORTS)
Just some nitpicking: I'd recommend to start writing also the cmake files in
good style, i.e. with proper indentation and consistent upper- or lower
casing.
Also, if there are no strong reasons against it, I'd recommend to require a
higher version of cmake, at least 2.8.0, better 2.8.3 or newer. This will give
you more features and bug fixes, braces in if()-conditions.
Then this code would look like:
cmake_minimum_required (VERSION 2.8)
if(WIN32)
set(REV_SRC reverse.cpp reverse.h)
else()
set (REV_SRC reverse.cpp)
endif()
add_definitions(-DREVERSE_EXPORTS)
Alex
More information about the CMake
mailing list