CMake taget_link_libraries无效

时间:2017-05-05 10:58:40

标签: c++ cmake

我正在尝试使用cmake编译程序。我写了一个CMakeLists.txt文件,但似乎语句“target_link_libraries”没有效果。我把“XXX”(不是库)放在库列表中,目的是测试它是否会给出“无法找到库XXX”这样的错误消息。不幸的是,我没有收到该消息,并且所有错误消息都是关于未定义的标识符,如果库已成功链接,则应该定义这些标识符。更重要的是,当我删除target_link_libraries语句并编译时,我得到了与之前相同的错误消息。这进一步表明target_link_libraries没有效果。你能帮我找一下CMakeLists.txt中的错误吗?我使用的是CentOS 6.8,编译器是intel icpc 2013 sp1.0.080。 提前谢谢!

cmake_minimum_required(VERSION 3.3)
project(OFcatalyst)

set(USE_CATALYST ON CACHE BOOL " ")
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_COMPILER /opt/intel/composer_xe_2013_sp1.0.080/bin/intel64/icpc)
#set(CMAKE_CXX_FLAGS -std=c++0x -fp-trap=common -fp-model precise -Dlinux64
#-DWM_DP -wd327,525,654,819,1125,1476,1505,1572 -xHost -O2 -no-prec-div -DNoRepository -fPIC)
set(FOAMDIR /opt/OpenFOAM/OpenFOAM-2.3.x)
set(FOAMSRC ${FOAMDIR}/src)
set(FOAMSOLVER ${FOAMDIR}/applications/solvers)
include_directories(
${FOAMSRC}/OSspecific/POSIX/lnInclude ${FOAMSRC}/OpenFOAM/lnInclude 
${FOAMSRC}/finiteVolume/lnInclude ${FOAMDIR}/interfacialModels/lnInclude 
${FOAMDIR}/phaseModel/lnInclude ${FOAMDIR}/kineticTheoryModels/lnInclude 
${FOAMSOLVER}/multiphase/bubbleFoam 
${FOAMSRC}/turbulenceModels/incompressible/turbulenceModel
${FOAMSRC}/transportModels
${FOAMSRC}/transportModels/incompressible/transportModel
${FOAMSRC}/transportModels/incompressible/singlePhaseTransportModel
${FOAMSRC}/meshTools/meshSearch
${FOAMSRC}/meshTools/lnInclude
${FOAMSRC}/lagrangian/basic/lnInclude)
set(srcfile runCatalyst.C internalWriter.C lagrangianWriter.C writeFuns.C
    writeFaceSet.C writePointSet.C writeSurfFields.C vtkMesh.C vtkTopo.C)
#link_directories(${FOAMDIR}/platforms/linux64IccDPOpt/lib)

if(USE_CATALYST)
find_package(ParaView 5.2 REQUIRED COMPONENTS vtkPVPythonCatalyst)
include("${PARAVIEW_USE_FILE}")
add_executable(${PROJECT_NAME} ${srcfile})
target_link_libraries(${PROJECT_NAME} LINK_PRIVATE vtkPVPythonCatalyst 
vtkParallelMPI m nsl dl OpenFOAM fileFormats finiteVolume 
triSurface twoPhaseMixture surfMesh meshTools XXX
incompressibleTransportModels incompressibleTurbulenceModel
incompressibleRASModels)
message(status "target-link-libraries is executed")
add_definitions("-DUSE_CATALYST")
if(NOT PARAVIEW_USE_MPI)
message(SEND_ERROR "ParaView must be built with MPI enabled")
endif()
include(vtkModuleMacros)
include(vtkMPI)
vtk_mpi_link(${PROJECT_NAME})
else()
find_package(MPI REQUIRED)
include_directories(${MPI_C_INCLUDE_PATH})
add_executable(${PROJECT_NAME} ${srcfile})
target_link_libraries(${PROJECT_NAME} LINK_PRIVATE ${MPI_LIBRARIES} 
m nsl dl OpenFOAM fileFormats finiteVolume 
triSurface twoPhaseMixture surfMesh meshTools
incompressibleTransportModels xxx
incompressibleTurbulenceModel
incompressibleRASModels)
endif()

0 个答案:

没有答案