[CMake] problem w/ "find_package"_ makefile does not always compile
ny
nikos.yiotis at gmail.com
Sun Jan 2 16:15:56 EST 2011
** Apologies for double-posting my earlier message got truncated **
greetings!
I spent enough time trying to make the software work,
so I'd be happy to get some feedback::
I built research code written in (templated) c++, size is approximately
~15K lines. I am on a mac and do not use Cocoa(/xcode), straight from
command line. Note that I choose to generate a Unix makefile, not an
xcode project and I am on snow leopard 10.6.5 w/ g++ 4.2.1.
The pain was that there were no makefile coming along w/ the project,
so I had to translate the *.vcproj file from scratch to CMakelists and
then convert it to makefile. My directories structure (directories marked
w/ DIR_ else are files, indentation denotes deeper level)::
DIR_4DMPU_exampleTest
4DMPU_example.cpp
DIR_ann_1.1.2
DIR_cmake
CMakeLists.txt
FindANN.cmake
Modules
FindANN.cmake
DIR_include
DIR_mc4d_tables
num_tet_table.cpp
tet_table.cpp
vert_table.cpp
DIR_4DMPU_exampleTestBin
In the cmake GUI I add:
ANN_LIBRARY
/Users/nikos/Downloads/4DMPU_exampleTest/ann_1.1.2/include
ANN_INCLUDE_DIR
/Users/nikos/Downloads/4DMPU_exampleTest/ann_1.1.2/lib/libANN.a
My CMakeLists.txt is::
cmake_minimum_required(VERSION 2.8)
project( 4DMPU_example )
SET (CMAKE_BUILD_TYPE DEBUG)
set(SOURCE_FILES
4DMPU_example.cpp
mc4d_tables/num_tet_table.cpp
mc4d_tables/tet_table.cpp
mc4d_tables/vert_table.cpp
)
set(INCLUDE_FILES
include/4dtables.h
include/ann_helper.h
... # more headers
include/Volume.h ann_1.1.2/include
include/VolumeIO.h
)
include_directories(
${PROJECT_SOURCE_DIR}/ann_1.1.2/include
${PROJECT_SOURCE_DIR}/ann_1.1.2/lib
include
)
INCLUDE(FindANN.cmake)
IF(ANN_FOUND)
INCLUDE_DIRECTORIES( ${ANN_INCLUDE_DIR} )
ENDIF(ANN_FOUND)
set(LIBS ${LIBS} ${ANN_LIBRARY})
add_executable( 4DMPU_example ${SOURCE_FILES} )
target_link_libraries( 4DMPU_example ${LIBS} )
and the content of the FindANN.cmake::
FIND_LIBRARY(ANN_LIBRARY lANN
${PROJECT_SOURCE_DIR}/ann_1.1.2/lib
)
FIND_PATH( ANN_INCLUDE_DIR ANN/ANN.h ANN/ANNperf.h ANN/ANNx.h
${PROJECT_SOURCE_DIR}/ann_1.1.2/include
)
IF(ANN_LIBRARY)
IF(ANN_INCLUDE_DIR)
SET(ANN_FOUND TRUE)
ENDIF(ANN_INCLUDE_DIR)
ENDIF(ANN_LIBRARY)
The project compiles fine this way.
Now, the problem is that if I follow the advice below
http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries#Using_external_libraries_in_your_project
and add the line
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/Modules/")
and, moreover, substitute
include_directories(
${PROJECT_SOURCE_DIR}/ann_1.1.2/include
${PROJECT_SOURCE_DIR}/ann_1.1.2/lib
include
)
with
find_package(ANN REQUIRED)
include_directories(${ANN_INCLUDE_DIR}
include
)
into CMakeLists.txt I get a linking problem.
I do not reproduce the message -> the point is that the ANN library is not
linked
w/ my object files. Can anyone tell me what I am doing wrong in the 2nd
case?
Note also that in the 2nd case I explicitly add::
ANN_DIR /Users/nikos/Downloads/4DMPU_exampleTest/cmake/Modules
in the cmake GUI.
Thanks for any pointers
N
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110102/21ddd02a/attachment.htm>
More information about the CMake
mailing list