[CMake] Sourcefiles compile but no library built

David Cole david.cole at kitware.com
Mon Aug 22 11:49:59 EDT 2011


Is it just a case-sensitive typo?

You say make complains that it can't find "libUtil.so" -- but your
actual library should be named "libutil.so" (lower case u) according
to your add_library call. (I'm assuming MIIND_LIBRARY_PREFIX is the
empty string...?)

If that's not it, you can use "make VERBOSE=1" to gather more details
about what is being built. You should see some sort of linking step
for your "util" target during a clean (start from scratch in an empty
build tree) make.


HTH,
David


On Mon, Aug 22, 2011 at 8:33 AM, Marc de Kamps <M.deKamps at leeds.ac.uk> wrote:
> Hi,
>
>
>
> Below you find a CMakeLists.txt that used to do what I needed: compile the
> source files and create a library. I recently changed from 2.6 to 2.8. The
> source files are being compiled, but the resulting so is nowhere to be
> found. There are no error messages:
>
>
>
> I have checked that the environment variables are all defined. This file
> lives in a directory called UtilLib, which resides in libs. libs has its own
> CMakeList.txt and uses ADD_SUBDIRECTORY to add the UtilLib directory. The
> CMakeList.txt of the main project and libs are added below.
>
>
>
> To my understanding, the fact that the source files are compiled indicates
> that CMake understands it needs to build this library, but it is nowhere to
> be found. Later in the process, another library which depends on this one
> cannot be built because make complains there is no rule to build libUtil.so.
>
>
>
> Is there an obvious mistake which would brake working files when moving from
> 2.6 to 2.8? This problem occurs under fedora linux.
>
>
>
> Is there a way to get more information on why the library is not built?
>
>
>
> Thanks,
>
> Marc
>
>
>
>
>
> --------------------------------------------------------------------------
>
> project( ${MIIND_LIBRARY_PREFIX}util )
>
>
>
> if( NOT WIN32 )
>
>   SET(LIB_TYPE SHARED)
>
> else( NOT WIN32 )
>
>   SET(LIB_TYPE STATIC)
>
> endif( NOT WIN32 )
>
>
>
> set( util_SRC
>
>                 AttributeList.cpp
>
>     UtilTest.cpp )
>
>
>
> set( util_HEADERS
>
>     AbstractException.h
>
>                 AttributeList.h
>
>     UtilLib.h
>
>     UtilTest.h )
>
>
>
> add_library( ${MIIND_LIBRARY_PREFIX}util ${LIB_TYPE} ${util_SRC}
> ${util_HEADERS})
>
>
>
> CMakeList.txt in libs
>
>
>
> ADD_SUBDIRECTORY( LayerMappingLib )
>
> ADD_SUBDIRECTORY( NetLib )
>
> ADD_SUBDIRECTORY( NumtoolsLib )
>
> ADD_SUBDIRECTORY( SparseImplementationLib )
>
> ADD_SUBDIRECTORY( StructnetLib )
>
> ADD_SUBDIRECTORY( UtilLib )
>
> ADD_SUBDIRECTORY( MiindLib )
>
>
>
> ‘Root’ CMakeList.txt
>
>
>
> project( miind )
>
> cmake_minimum_required(VERSION 2.6)
>
> set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
> ${PROJECT_SOURCE_DIR}/cmake-modules )
>
> set( CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING "Install prefix." ) #
> default install prefix. can be set with ccmake
>
>
>
>
>
> set( MIIND_LIBRARY_PREFIX "miind" CACHE STRING "prefix string for all libs"
> )
>
>
>
>
>
> if (WIN32)
>
>         ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS
> -DBOOST_PROGRAM_OPTIONS_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK)
>
> else (WIN32)
>
>         ADD_DEFINITIONS( -Wall ) # Extra compile options, just under Unix.
> This would set /W4 underwindows
>
> endif (WIN32)
>
>
>
> # This used to be done with CMAKE_CXX_FLAG, however this is a  crude method
> overriding sensible default settings on some platforms
>
> SET(SWIG_COMPILE_OPTIONS "-fno-strict-aliasing" ) # gnu optimising is too
> agressive for SWIG produced code according to SWIG documentation
>
>
>
> #check for third party libraries
>
> find_package( PkgConfig )
>
>
>
> MARK_AS_ADVANCED( USE_FFTWD )
>
> OPTION( USE_FFTWD "Use double precision FFTW if found" ON )
>
> MARK_AS_ADVANCED( USE_FFTWF )
>
> OPTION( USE_FFTWF "Use single precision FFTW if found" ON )
>
>
>
> find_package( FFTW )
>
> find_package( Boost COMPONENTS unit_test_framework program_options)
>
> if( Boost_FOUND )
>
>    message("Boost found setting up directories")
>
>    message("BOOST_ROOT: " ${BOOST_ROOT} )
>
>    message("Boost include directories:" ${Boost_INCLUDE_DIR} )
>
>    message("Boost library directories:" ${Boost_LIBRARY_DIRS} )
>
>    include_directories( ${Boost_INCLUDE_DIR} )
>
>    link_directories( ${Boost_LIBRARY_DIR} )
>
> else ( Boost_FOUND )
>
>    message("Boost is mandatory to build the libraries")
>
> endif( Boost_FOUND )
>
>
>
> find_package( Root )
>
> if( ROOT_FOUND )
>
>   message("Building Root dependent parts")
>
> else( ROOT_FOUND )
>
>   message("Building parts not depending on Root")
>
> endif( ROOT_FOUND )
>
>
>
> # TODO:  This is ugly and must be fixed in the windows install procedure
>
> if (WIN32)
>
> SET (LIB_PREFIX lib)
>
> else (WIN32)
>
> SET (CBLAS_PREFIX gsl)
>
> endif (WIN32)
>
> #----------------swig
>
> FIND_PACKAGE( SWIG )
>
>
>
> if (SWIG_FOUND)
>
>         INCLUDE( ${SWIG_USE_FILE} )
>
>         FIND_PACKAGE( PythonLibs )
>
>         INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_PATH} )
>
> endif (SWIG_FOUND)
>
>
>
> SET( CMAKE_SWIG_FLAGS "" )
>
> #---------swig
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list