Stefan Radonjic
Stefan Radonjic

Reputation: 1598

CMake error - " Some (but not all) targets in this export set were already defined."

I am trying to build a library that is dependent on GDCM. So, I've installed GDCM following instructions that were provided in INSTAL.txt file and did not have any trouble doing it. But, when I tried to use cmake to build the library that is dependent on it, I am getting following message:

CMake Error at /usr/local/lib/gdcm-3.0/GDCMTargets.cmake:37 (message):
  Some (but not all) targets in this export set were already defined.

  Targets Defined:
  gdcmjpeg8;gdcmjpeg12;gdcmjpeg16;gdcmuuid;gdcmCommon;gdcmDICT;gdcmDSED;gdcmIOD;gdcmMSFF


  Targets not yet defined:
  gdcmexpat;gdcmopenjp2;gdcmcharls;gdcmzlib;socketxx;gdcmMEXD

Call Stack (most recent call first):
  /usr/local/lib/gdcm-3.0/GDCMConfig.cmake:39 (include)
  CMakeLists.txt:109 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/stefan/Desktop/BioClinica/bdtk/CMakeFiles/CMakeOutput.log".
See also "/home/stefan/Desktop/BioClinica/bdtk/CMakeFiles/CMakeError.log

Here is a portion of the code (from reported line GDCMConfig.make:37) from /usr/local/lib/gdcm-3.8/GDCMConfig.make file:

if(EXISTS ${SELF_DIR}/GDCMTargets.cmake)
  # This is an install tree
  include(${SELF_DIR}/GDCMTargets.cmake)
  get_filename_component(GDCM_INCLUDE_ROOT "${SELF_DIR}/../../include/gdcm-3.0" ABSOLUTE)
  set(GDCM_INCLUDE_DIRS ${GDCM_INCLUDE_ROOT})
  get_filename_component(GDCM_LIB_ROOT "${SELF_DIR}/../../lib" ABSOLUTE)
  set(GDCM_LIBRARY_DIRS ${GDCM_LIB_ROOT})
else()
  if(EXISTS ${SELF_DIR}/GDCMExports.cmake)
    # This is a build tree
    set( GDCM_INCLUDE_DIRS "/home/stefan/gdcm-3.0.7/gdcm/Source/Common;/home/stefan/gdcm-3.0.7/gdcmbin/Source/Common;/home/stefan/gdcm-3.0.7/gdcm/Source/DataStructureAndEncodingDefinition;/home/stefan/gdcm-3.0.7/gdcm/Source/MediaStorageAndFileFormat;/home/stefan/gdcm-3.0.7/gdcm/Source/MessageExchangeDefinition;/home/stefan/gdcm-3.0.7/gdcm/Source/DataDictionary;/home/stefan/gdcm-3.0.7/gdcm/Source/InformationObjectDefinition")
    set(GDCM_LIBRARY_DIRS "/home/stefan/gdcm-3.0.7/gdcmbin/bin/.")

    include(${SELF_DIR}/GDCMExports.cmake)

  else()
    message(FATAL_ERROR "ooops")
  endif()
endif()

Upvotes: 2

Views: 1333

Answers (1)

ferdymercury
ferdymercury

Reputation: 828

It's likely that you are calling find_package on another library such as ITK before calling find_package on GDCM, and that ITK was built by hand with a custom version of GDCM rather than the system-default version.

Solution is to either set -DGDCM_DIR to the ITK builtin-version path, or to recompile ITK with the flag -DITK_USE_SYSTEM_GDCM=ON as suggested here.

Upvotes: 0

Related Questions