Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not make install step when building external project with cmake

I'm building dependency project with cmake ExternalProject_Add command:

include(ExternalProject)
...
set(COMMON_BASE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CommonBase)

ExternalProject_Add(CommonBaseProject
  SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
  BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
  INSTALL_COMMMAND ""
)   

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${COMMON_BASE_PROJECT_DIR}/include)

add_library(
    ${LIBRARY_NAME}
    SHARED
    ${SRC_FILES}
    ${INCLUDE_FILES}
)

target_link_libraries (Bios ${COMMON_BASE_PROJECT_DIR}/build/libCommonBase.dll)
add_dependencies(Bios CommonBaseProject)

but i get error:

[100%] Linking CXX shared library libCommonBase.dll
[100%] Built target CommonBase
[ 50%] Performing install step for 'CommonBaseProject'
make[3]: *** No rule to make target 'install'.  Stop.

I don't need to make install step, so my question is: how to disable it?

like image 217
Vyacheslav Avatar asked Jun 15 '16 14:06

Vyacheslav


2 Answers

You almost had it: Instead of INSTALL_COMMAND "" put something like

    INSTALL_COMMAND cmake -E echo "Skipping install step."
like image 178
James Hirschorn Avatar answered Oct 26 '22 10:10

James Hirschorn


You can generate a target for the build step with STEP_TARGETS build and add dependency on this particular target. The step targets are named <external-project-name>-<step-name> so in this case the target representing the build step will be named CommonBaseProject-build.

You probably also want to exclude the CommonBaseProject from the "all" target with EXCLUDE_FROM_ALL TRUE.

ExternalProject_Add(CommonBaseProject
  SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
  BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
  STEP_TARGETS build
  EXCLUDE_FROM_ALL TRUE
)

add_dependencies(Bios CommonBaseProject-build)
like image 12
Paweł Bylica Avatar answered Oct 26 '22 09:10

Paweł Bylica