[CMake] Baffled by CDT4 link_directories

Dan Furtney dfurtney at cox.net
Fri May 6 01:21:49 EDT 2011


I have a CMakelists.txt file that works properly for the “Unix Makefiles” type build (Linux) and for VS 2008. When generating a CDT4 project (Linux) from the same file, library paths are not resolved and the project won’t link. The library paths are specified using the link_directories command exclusively.  The cmake files are at the same level as the “Src” directory that contains all source. I am totally stumped as to why this doesn’t work under CDT4.

cmake_minimum_required(VERSION 2.6)
project(SecondTest_UT)

# Compiler options
if(CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "-m32 -D USE_STD_HEADERS -D NO_CSF_INTEROPERABILITY")
elseif(MSVC)
   add_definitions(/MTd )
endif(CMAKE_COMPILER_IS_GNUCXX)

# Platform dependency controls
if(WIN32)
   set(COE_OS windows)
   set(COE_LIB_DIR nt)
   set(GENSOFT_LIB_DIR NTLib_80)
   set(LIB_EXTENSION .lib)
   set(PLATFORM_SPECIFIC_LIBS ws2_32.lib)
   set(PLATFORM_SPECIFIC_LINK_DIRS $ENV{COE}/lib/${COE_LIB_DIR})
   set(PLATFORM_SPECIFIC_INC_DIRS )
elseif(UNIX)
   set(COE_OS posix)
   set(COE_LIB_DIR linux_pc)
   set(GENSOFT_LIB_DIR Linux)
   set(LIB_EXTENSION )
   set(PLATFORM_SPECIFIC_LIBS gs_esw eswHelpers Infrastructure)
   set(PLATFORM_SPECIFIC_LINK_DIRS $ENV{SIMDIR}/lib $ENV{ESWDIR}/Esw)
   set(PLATFORM_SPECIFIC_INC_DIRS $ENV{SIMDIR}/sim/src/dropIns/eswInterface/eswHelpers $ENV{SIMDIR}/sm3Sim/src/dropIns/eswInterface/eswHelpers/intLibStub)
endif(WIN32)

# COE and genSoft Includes
include_directories(AFTER 
   $ENV{GTEST_ROOT}/include
   $ENV{GENSOFT_HOME}/include
   $ENV{GENSOFT_HOME}/include/genMath
   $ENV{GENSOFT_HOME}/include/genSoftLLE
   $ENV{GENSOFT_HOME}/include/genSoftLog
   $ENV{COE}/include
   $ENV{COE}/include/${COE_OS}
)

# GS-ESW Includes
include_directories(AFTER 
   ${PLATFORM_SPECIFIC_INC_DIRS}
)

# Library directory paths
link_directories(
   $ENV{GTEST_ROOT}/lib
   $ENV{COE}/lib/${COE_LIB_DIR}/cpp
   ${PLATFORM_SPECIFIC_LINK_DIRS}
   $ENV{GENSOFT_HOME}/lib/genSoftComponentFramework_${GENSOFT_LIB_DIR}
)

# Additional Libraries
set(GENSOFT_LIBS genSoftD${LIB_EXTENSION} coeD${LIB_EXTENSION} od_coeD${LIB_EXTENSION} socket_media_bindingD${LIB_EXTENSION})
set(GTEST_LIBS gtest_maind${LIB_EXTENSION} gtestd${LIB_EXTENSION})

# Get local files
file(GLOB_RECURSE fileNameListStr Src/*.cpp)

# Add the targets
add_library(SecondTest SHARED ${fileNameListStr})
add_executable(SecondTestExec ${fileNameListStr})

# Associate the additional libs with the targets
target_link_libraries(SecondTestExec ${GTEST_LIBS} ${GENSOFT_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
target_link_libraries(SecondTest ${GTEST_LIBS} ${GENSOFT_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110505/2d4d86e1/attachment-0001.htm>


More information about the CMake mailing list