Building a library using autotools from cmake

前端 未结 2 441
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 08:50

This is my first try with cmake and I would like to have, if possible, some feedbacks about what I did since some problems remain.

In the CMakeLists.txt of the library f

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 09:35

    I think that you'd be better off using the ExternalProject feature of cmake. I guess you have your project and have libantrl in a sub directory?

    project
          +- libantlr
          +- mysrc
      ---- etc ----
    

    If that's the case, you can do something like this in the top level CMakeLists.txt:

    cmake_minimum_required(VERSION 2.8)
    project(test)
    include(ExternalProject)
    ExternalProject_Add(libantlr
        SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libantlr
        CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/libantlr/configure --prefix=
        BUILD_COMMAND ${MAKE})
    

    The is expanded to something like libantlr-prefix, so things are installed in your build tree rather than in /usr/local, which is what autotools would do without a prefix.

提交回复
热议问题