Skip to content

Commit

Permalink
merge to one single catkin package with one high-level CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Winkler committed Jun 19, 2018
1 parent eb1f530 commit e628474
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 280 deletions.
File renamed without changes.
87 changes: 84 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,91 @@
# At LEAST 2.8 but newer is better
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(ifopt)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(Eigen3 REQUIRED)
find_package(catkin QUIET) # optional: allows to be found in catkin workspace
find_package(GTest QUIET) # optional: enables/disables testing


################
## Find IPOPT ##
################
# adapt this to point to your installed IPOPT folder
set(IPOPT_DIR "/home/winklera/3rd_party_software/Ipopt-3.12.8")
if(IS_DIRECTORY ${IPOPT_DIR}/build/include/coin)
set(IFOPT_IPOPT_LIB ifopt_ipopt)
set(IPOPT_INCLUDE_DIRS ${IPOPT_DIR}/build/include/coin)
find_library(IPOPT_LIB ipopt ${IPOPT_DIR}/build/lib)
else()
message(WARNING "IPOPT directory \"" ${IPOPT_DIR} "\" NOT found "
"-> Not compiling ifopt_ipopt. \n"
"Specify path to your installed IPOPT installation here.")
endif()


################
## Find SNOPT ##
################
# adapt this to point to your installed IPOPT folder
set(SNOPT_DIR "/home/winklera/3rd_party_software/snopt_lib")
set(SNOPT76 FALSE) # set to TRUE if using Snopt 7.6 or greater
if(IS_DIRECTORY ${SNOPT_DIR}/include)
set(IFOPT_SNOPT_LIB ifopt_snopt)
set(SNOPT_INCLUDE_DIRS ${SNOPT_DIR}/include)
find_library(SNOPT_LIB1 snopt7_cpp ${SNOPT_DIR}/lib)
find_library(SNOPT_LIB2 snopt7 ${SNOPT_DIR}/lib)

if(${SNOPT76})
message("SNOPT version >= SNOPT 7.6 detected")
endif()
else()
message(WARNING "SNOPT directory \"" ${SNOPT_DIR} "\" NOT found "
"-> Not compiling ifopt_snopt.\n"
"Specify path to your installed SNOPT installation here.")
endif()


##############################################
## catkin specific configuration (optional) ##
##############################################
# This can then be used to "find_package(ifopt)" if built with catkin
if (catkin_FOUND)
catkin_package(
INCLUDE_DIRS ifopt_core/include
ifopt_ipopt/include ${IPOPT_INCLUDE_DIRS}
ifopt_snopt/include ${SNOPT_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}

LIBRARIES ifopt_core
${IFOPT_IPOPT_LIB} ${IPOPT_LIB}
${IFOPT_SNOPT_LIB} ${SNOPT_LIB1} ${SNOPT_LIB2}

DEPENDS eigen
)
endif()


###########
## Build ##
###########
# Default to Release build
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

add_subdirectory(ifopt_core)

add_subdirectory(ifopt_ipopt)
add_subdirectory(ifopt_snopt)
if (IFOPT_IPOPT_LIB)
add_subdirectory(ifopt_ipopt)
endif()

if (IFOPT_SNOPT_LIB)
add_subdirectory(ifopt_snopt)
endif()




22 changes: 0 additions & 22 deletions ifopt/CHANGELOG.rst

This file was deleted.

4 changes: 0 additions & 4 deletions ifopt/CMakeLists.txt

This file was deleted.

32 changes: 0 additions & 32 deletions ifopt/package.xml

This file was deleted.

36 changes: 4 additions & 32 deletions ifopt_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(ifopt_core)


#find_package(catkin REQUIRED)
find_package(Eigen3 REQUIRED)


###################################
## catkin specific configuration ##
###################################
#catkin_package(
# INCLUDE_DIRS include ${EIGEN3_INCLUDE_DIR}
# LIBRARIES ${PROJECT_NAME}
#)


###########
## Build ##
###########
add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} SHARED
src/problem.cc
src/composite.cc
src/leaves.cc
Expand Down Expand Up @@ -50,25 +36,11 @@ target_compile_options(${PROJECT_NAME} PUBLIC -std=c++11)
#############
## Testing ##
#############
#if (CATKIN_ENABLE_TESTING)
#catkin_add_gtest(${PROJECT_NAME}-test
# test/gtest_main.cc
# test/composite_test.cc
# test/problem_test.cc)
#if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test
# ${PROJECT_NAME}
# pthread
# )
#endif()
#endif()


find_package(GTest QUIET)
if (GTEST_FOUND)
message(STATUS "GTest found -> Building IFOPT test executable \"testifopt\"")
add_executable(testifopt test/composite_test.cc
test/problem_test.cc)
test/problem_test.cc)

target_link_libraries(testifopt PRIVATE ${PROJECT_NAME} GTest::GTest GTest::Main)
target_link_libraries(testifopt PRIVATE
${PROJECT_NAME} GTest::GTest GTest::Main)
endif()
27 changes: 0 additions & 27 deletions ifopt_ipopt/CHANGELOG.rst

This file was deleted.

49 changes: 7 additions & 42 deletions ifopt_ipopt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,21 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(ifopt_ipopt)

#find_package(catkin REQUIRED)


################
## Find IPOPT ##
################
# adapt this to point to your installed IPOPT folder
set(IPOPT_DIR "/home/winklera/3rd_party_software/Ipopt-3.12.8")
if(IS_DIRECTORY ${IPOPT_DIR}/build/include/coin)
set(IPOPT_INCLUDE_DIRS ${IPOPT_DIR}/build/include/coin)
set(IPOPT_LIBRARIES ${IPOPT_DIR}/build/lib/libipopt.so)
else()
message(WARNING "IPOPT directory \"" ${IPOPT_DIR} "\" NOT found "
"-> Not compiling ifopt_ipopt. \n"
"Specify path to your installed IPOPT installation here.")
return()
endif()


#################################
## Generate cmake config files ##
#################################
# These can then be used to "find_package(ifopt_ipopt)"
#catkin_package(
# INCLUDE_DIRS include ${IPOPT_INCLUDE_DIRS} ${ifopt_core_INCLUDE_DIRS}
# LIBRARIES ${PROJECT_NAME}
#)


###########
## Build ##
###########
# The IPOPT solver interface
add_library(${PROJECT_NAME} STATIC src/ipopt_adapter.cc)
target_include_directories(${PROJECT_NAME} PUBLIC
add_library(${PROJECT_NAME} SHARED src/ipopt_adapter.cc)
target_include_directories(${PROJECT_NAME} PUBLIC
include
${IPOPT_INCLUDE_DIRS}
${ifopt_core_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME} PUBLIC
ifopt_core
${IPOPT_LIBRARIES}
target_link_libraries(${PROJECT_NAME}
PUBLIC ifopt_core
PRIVATE ${IPOPT_LIB}
)

#target_link_libraries(${PROJECT_NAME} PUBLIC
# ${ifopt_core_LIBRARIES}
# ${IPOPT_LIBRARIES}
#)


#############
## Install ##
Expand All @@ -76,10 +41,10 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
#############
## Testing ##
#############
find_package(GTest QUIET)
if (GTEST_FOUND)
message(STATUS "GTest found -> Building IPOPT test executable \"testipopt\"")
add_executable(testipopt test/ex_test_ipopt.cc)

target_link_libraries(testipopt PRIVATE ${PROJECT_NAME} GTest::GTest GTest::Main)
target_link_libraries(testipopt PRIVATE
${PROJECT_NAME} GTest::GTest GTest::Main)
endif()
23 changes: 0 additions & 23 deletions ifopt_ipopt/package.xml

This file was deleted.

26 changes: 0 additions & 26 deletions ifopt_snopt/CHANGELOG.rst

This file was deleted.

Loading

0 comments on commit e628474

Please sign in to comment.