CMake error while configuring “install TARGETS giv

2019-04-10 05:41发布

问题:

I'm trying to use CMake to configure assimp's samples

but there are some error while configuring

I've tried lot's of method but no one works.

CMake Error at CMakeLists.txt:41 (INSTALL):
      install TARGETS given no RUNTIME DESTINATION for executable target
      "assimp_simpletexturedogl".


    CMake Warning (dev) in CMakeLists.txt:
      No cmake_minimum_required command is present.  A line of code such as

        cmake_minimum_required(VERSION 3.2)

      should be added at the top of the file.  The version specified may be lower
      if you wish to support older CMake versions for this project.  For more
      information run "cmake --help-policy CMP0000".
    This warning is for project developers.  Use -Wno-dev to suppress it.

    Configuring incomplete, errors occurred!
    See also "D:/OpenGL/assimp-3.1.1-win-binaries/samples/SimpleTexturedOpenGL/made/CMakeFiles/CMakeOutput.log".

Here is my CMakeLists.txt, any idea would be appreciate.

I'm using MSVC2013 to compile.

FIND_PACKAGE(OpenGL)
FIND_PACKAGE(GLUT)

IF ( NOT GLUT_FOUND )
    IF ( MSVC )
        SET ( GLUT_FOUND 1 )
        SET ( GLUT_INCLUDE_DIR ${Assimp_SOURCE_DIR}/samples/glut/ )
        SET ( GLUT_LIBRARIES ${Assimp_SOURCE_DIR}/samples/glut/glut32.lib )
    ELSE ( MSVC )
        MESSAGE( WARNING "Please install glut." )
    ENDIF ( MSVC )
ENDIF ( NOT GLUT_FOUND )

INCLUDE_DIRECTORIES(
    ${Assimp_SOURCE_DIR}/include
    ${Assimp_SOURCE_DIR}/code
    ${OPENGL_INCLUDE_DIR}
    ${GLUT_INCLUDE_DIR}
    ${Assimp_SOURCE_DIR}/samples/DevIL/include/
)

LINK_DIRECTORIES( 
    ${Assimp_BINARY_DIR} 
    ${Assimp_BINARY_DIR}/lib/
    ${Assimp_SOURCE_DIR}/samples/DevIL/lib/
)

ADD_EXECUTABLE( assimp_simpletexturedogl WIN32
    SimpleTexturedOpenGL/include/boost_includes.h
    SimpleTexturedOpenGL/src/model_loading.cpp
)

SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX})

TARGET_LINK_LIBRARIES( assimp_simpletexturedogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} DevIL.lib )

SET_TARGET_PROPERTIES( assimp_simpletexturedogl PROPERTIES
    OUTPUT_NAME assimp_simpletexturedogl
)

INSTALL( TARGETS assimp_simpletexturedogl
    DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
) 

回答1:

You forgot to indicate a folder for the executable. Try this:

INSTALL( 

     TARGETS assimp_simpletexturedogl
     RUNTIME DESTINATION bin
     DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
) 

I don't know why in cMake is a requirement to have a drop folder ( bin in my example ) for the executable, but this is the problem here.



回答2:

I ran into this tonight and after a crash course in cmake I tried cmake --trace-expand which showed a bunch of variables were blank, including ${ASSIMP_BIN_INSTALL_DIR}.

At which point I just loaded the .sln file with vs2015 community, let it upgrade it, and then set the needed things by hand.

Building assimp 3.2 from sources was necessary and cmake worked fine for this. I also chose to edit the output file names to exclude the -mtd-130, i.e. set them to inherit from project defaults.

It works for me, hope that helps somebody until the sample cmakelist files are updated.



回答3:

I got this to work simply by doing the following:

mkdir build
cd build
cmake .. -DASSIMP_BIN_INSTALL_DIR=`pwd`


回答4:

For example:

install(TARGETS snappy
        EXPORT SnappyTargets
        # RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # DESTINATION error
        RUNTIME DESTINATION bin ${CMAKE_INSTALL_BINDIR} # should add bin or other dir
        LIBRARY DESTINATION lib ${CMAKE_INSTALL_LIBDIR}
        # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR # DESTINATION error
        ARCHIVE DESTINATION lib ${CMAKE_INSTALL_LIBDIR} # should add lib
)

Related to this question