Am 14.01.2014 19:10, schrieb Dimitri Maziuk:
> On 01/14/2014 11:21 AM, Vedat Durmaz wrote:
> ...
>> i really don't
>> understand, why obabel building is deactivated by default in the static
>> case. however, i also don't have that much experience with that
>> cmake/configure stuff.
> Looks like a braino to me, perhaps the endif(BUILD_SHARED) was supposed
> to be about 10 lines above where it is now?

but then still no obabel executable would have been compiled/linked in
case of a static build. maybe i haven't explained (and understood) well
enough. i don't know whether this will work, but i'll try to attach the
CMakeLists.txt file from the ./tools directory before and after
modification (concerning the last 1-15 lines only) ..

vedat
>
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today. 
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
>
>
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

if(MINIMAL_BUILD)
  set(tools
        babel
  )
else(MINIMAL_BUILD)
  set(tools
        babel
        obabel
        obchiral
        obconformer
        obenergy
        obfit
        obgen
        obminimize
        obprobe
        obprop
        obrotamer
        obrotate
     )
  if(EIGEN3_FOUND)
    set(tools
        ${tools}
        obrms
       )
  endif()
endif(MINIMAL_BUILD)

INCLUDE(CheckFunctionExists)
SET(GETOPT getopt)
CHECK_FUNCTION_EXISTS(${GETOPT} GETOPT_FOUND)

if(BUILD_SHARED)
  foreach(tool ${tools})
    add_executable(${tool} ${tool}.cpp)
    target_link_libraries(${tool} ${BABEL_LIBRARY})
    install(TARGETS ${tool}
                    RUNTIME DESTINATION bin
                    LIBRARY DESTINATION lib
                    ARCHIVE DESTINATION lib
    )
  endforeach(tool)

  if(NOT MINIMAL_BUILD)
    # obspectrophore -- requires getopt
    if (NOT GETOPT_FOUND)
      add_executable(obspectrophore obspectrophore.cpp getopt.c)
    else(NOT GETOPT_FOUND)
      add_executable(obspectrophore obspectrophore.cpp)
    endif(NOT GETOPT_FOUND)
    target_link_libraries(obspectrophore ${BABEL_LIBRARY})
    install(TARGETS obspectrophore
                    RUNTIME DESTINATION bin
                    LIBRARY DESTINATION lib
                    ARCHIVE DESTINATION lib
    )

    # obgrep -- requires getopt
    if (NOT GETOPT_FOUND)
      add_executable(obgrep obgrep.cpp getopt.c)
    else(NOT GETOPT_FOUND)
      add_executable(obgrep obgrep.cpp)
    endif(NOT GETOPT_FOUND)
      target_link_libraries(obgrep ${BABEL_LIBRARY})
      install(TARGETS obgrep
                      RUNTIME DESTINATION bin
                      LIBRARY DESTINATION lib
                      ARCHIVE DESTINATION lib
      )
  endif(NOT MINIMAL_BUILD)

else(BUILD_SHARED)
###############################################################################
#
# Build STATIC babel with all plugins taken from the static libopenbabel.a
#
###############################################################################

  # Set libs to imported openbabel target
  set(libs openbabel)
  if(WITH_STATIC_INCHI)
    set(libs ${libs} ${LIBXML2_LIBRARIES})
  endif()
  if(WITH_STATIC_LIBXML)
    set(libs ${libs} inchi)
  endif()

  if(NOT MSVC)
    find_package(Threads)
    if(CMAKE_USE_PTHREADS_INIT)
      if(BUILD_MIXED)
        set(libs ${libs} ${CMAKE_THREAD_LIBS_INIT})
      else()
        # Make sure to find the static library with .a suffix (see 
CMAKE_FIND_LIBRARY_SUFFIXES)
        find_library(PTHREAD_LIBRARY NAMES pthread)
        if(PTHREAD_LIBRARY)
          set(libs ${libs} ${PTHREAD_LIBRARY})
        endif()
      endif()
    endif()

    if(BUILD_MIXED)
      if(CMAKE_COMPILER_IS_GNUCXX)
        if(CMAKE_SYSTEM_NAME MATCHES Linux)

          #
          # Relocatable binaries on linux using -static-libgcc. (GCC only)
          #
          set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
          # make sure the linker will find the static libstdc++
          file(REMOVE "${CMAKE_BINARY_DIR}/libstdc++.a")
          execute_process(COMMAND "g++" "-print-file-name=libstdc++.a"
                          OUTPUT_VARIABLE libstdcpp
                          OUTPUT_STRIP_TRAILING_WHITESPACE)
          execute_process(COMMAND "ln" "-s" "${libstdcpp}"
                          WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

          link_directories(${CMAKE_BINARY_DIR})

        endif(CMAKE_SYSTEM_NAME MATCHES Linux)
      endif(CMAKE_COMPILER_IS_GNUCXX)
    else(BUILD_MIXED)
      #
      # Default static build using GNU-like compiler.
      #
      if (NOT APPLE)
            set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
      endif()
      # APPLE doesn't use -static
    endif(BUILD_MIXED)
  endif()

  # build a static babel only
  add_executable(babel babel.cpp)
  target_link_libraries(babel ${libs})

  if(NOT BUILD_MIXED)
    # Prevent -Wl,-Bdynamic from being added to the end of the link line.
    set_target_properties(babel PROPERTIES LINK_SEARCH_END_STATIC TRUE)
  endif(NOT BUILD_MIXED)

  install(TARGETS babel
          RUNTIME DESTINATION bin
          LIBRARY DESTINATION lib
          ARCHIVE DESTINATION lib)
endif(BUILD_SHARED)
if(MINIMAL_BUILD)
  set(tools
        babel
  )
else(MINIMAL_BUILD)
  set(tools
        babel
        obabel
        obchiral
        obconformer
        obenergy
        obfit
        obgen
        obminimize
        obprobe
        obprop
        obrotamer
        obrotate
     )
  if(EIGEN3_FOUND)
    set(tools
        ${tools}
        obrms
       )
  endif()
endif(MINIMAL_BUILD)

INCLUDE(CheckFunctionExists)
SET(GETOPT getopt)
CHECK_FUNCTION_EXISTS(${GETOPT} GETOPT_FOUND)

if(BUILD_SHARED)
  foreach(tool ${tools})
    add_executable(${tool} ${tool}.cpp)
    target_link_libraries(${tool} ${BABEL_LIBRARY})
    install(TARGETS ${tool}
                    RUNTIME DESTINATION bin
                    LIBRARY DESTINATION lib
                    ARCHIVE DESTINATION lib
    )
  endforeach(tool)

  if(NOT MINIMAL_BUILD)
    # obspectrophore -- requires getopt
    if (NOT GETOPT_FOUND)
      add_executable(obspectrophore obspectrophore.cpp getopt.c)
    else(NOT GETOPT_FOUND)
      add_executable(obspectrophore obspectrophore.cpp)
    endif(NOT GETOPT_FOUND)
    target_link_libraries(obspectrophore ${BABEL_LIBRARY})
    install(TARGETS obspectrophore
                    RUNTIME DESTINATION bin
                    LIBRARY DESTINATION lib
                    ARCHIVE DESTINATION lib
    )

    # obgrep -- requires getopt
    if (NOT GETOPT_FOUND)
      add_executable(obgrep obgrep.cpp getopt.c)
    else(NOT GETOPT_FOUND)
      add_executable(obgrep obgrep.cpp)
    endif(NOT GETOPT_FOUND)
      target_link_libraries(obgrep ${BABEL_LIBRARY})
      install(TARGETS obgrep
                      RUNTIME DESTINATION bin
                      LIBRARY DESTINATION lib
                      ARCHIVE DESTINATION lib
      )
  endif(NOT MINIMAL_BUILD)

else(BUILD_SHARED)
###############################################################################
#
# Build STATIC babel with all plugins taken from the static libopenbabel.a
#
###############################################################################

  # Set libs to imported openbabel target
  set(libs openbabel)
  if(WITH_STATIC_INCHI)
    set(libs ${libs} ${LIBXML2_LIBRARIES})
  endif()
  if(WITH_STATIC_LIBXML)
    set(libs ${libs} inchi)
  endif()

  if(NOT MSVC)
    find_package(Threads)
    if(CMAKE_USE_PTHREADS_INIT)
      if(BUILD_MIXED)
        set(libs ${libs} ${CMAKE_THREAD_LIBS_INIT})
      else()
        # Make sure to find the static library with .a suffix (see 
CMAKE_FIND_LIBRARY_SUFFIXES)
        find_library(PTHREAD_LIBRARY NAMES pthread)
        if(PTHREAD_LIBRARY)
          set(libs ${libs} ${PTHREAD_LIBRARY})
        endif()
      endif()
    endif()

    if(BUILD_MIXED)
      if(CMAKE_COMPILER_IS_GNUCXX)
        if(CMAKE_SYSTEM_NAME MATCHES Linux)

          #
          # Relocatable binaries on linux using -static-libgcc. (GCC only)
          #
          set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
          # make sure the linker will find the static libstdc++
          file(REMOVE "${CMAKE_BINARY_DIR}/libstdc++.a")
          execute_process(COMMAND "g++" "-print-file-name=libstdc++.a"
                          OUTPUT_VARIABLE libstdcpp
                          OUTPUT_STRIP_TRAILING_WHITESPACE)
          execute_process(COMMAND "ln" "-s" "${libstdcpp}"
                          WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

          link_directories(${CMAKE_BINARY_DIR})

        endif(CMAKE_SYSTEM_NAME MATCHES Linux)
      endif(CMAKE_COMPILER_IS_GNUCXX)
    else(BUILD_MIXED)
      #
      # Default static build using GNU-like compiler.
      #
      if (NOT APPLE)
            set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
      endif()
      # APPLE doesn't use -static
    endif(BUILD_MIXED)
  endif()

  # build a static babel only
  add_executable(babel babel.cpp)
  target_link_libraries(babel ${libs})

  if(NOT BUILD_MIXED)
    # Prevent -Wl,-Bdynamic from being added to the end of the link line.
    set_target_properties(babel PROPERTIES LINK_SEARCH_END_STATIC TRUE)
  endif(NOT BUILD_MIXED)

  install(TARGETS babel
          RUNTIME DESTINATION bin
          LIBRARY DESTINATION lib
          ARCHIVE DESTINATION lib)
          
  ### VEDAT:    build a static obabel
  add_executable(obabel obabel.cpp)
  target_link_libraries(obabel ${libs})

  if(NOT BUILD_MIXED)
    # Prevent -Wl,-Bdynamic from being added to the end of the link line.
    set_target_properties(obabel PROPERTIES LINK_SEARCH_END_STATIC TRUE)
  endif(NOT BUILD_MIXED)

  install(TARGETS obabel
          RUNTIME DESTINATION bin
          LIBRARY DESTINATION lib
          ARCHIVE DESTINATION lib)
          
  

endif(BUILD_SHARED)
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to