Skip to content

Commit 156bb19

Browse files
author
Frederic Py
committed
Big overhaul and cmake files, moving code to c++17, europa and lsts should work, python to be ported
1 parent fd515ce commit 156bb19

177 files changed

Lines changed: 4988 additions & 15608 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -33,79 +33,38 @@
3333
# POSSIBILITY OF SUCH DAMAGE. #
3434
#######################################################################
3535

36-
cmake_minimum_required(VERSION 2.8)
36+
cmake_minimum_required(VERSION 3.0)
3737
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/;${CMAKE_SOURCE_DIR}/cmake/Modules/")
38-
39-
########################################################################
40-
# remove annoying warning since cmake 3 #
41-
########################################################################
42-
if(CMAKE_MAJOR_VERSION GREATER 2)
43-
cmake_policy(SET CMP0042 NEW)
44-
endif()
45-
46-
# Do the prep for OSX 10.11
47-
set(DEST_LIB ${CMAKE_INSTALL_PREFIX}/lib)
48-
49-
if(APPLE)
50-
set(CMAKE_MACOSX_RPATH ON)
51-
# use, i.e. don't skip the full RPATH for the build tree
52-
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
53-
54-
# when building, don't use the install RPATH already
55-
# (but later on when installing)
56-
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
57-
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
58-
59-
# add the automatically determined parts of the RPATH
60-
# which point to directories outside the build tree to the install RPATH
61-
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
62-
63-
# the RPATH to be used when installing, but only if it's not a system directory
64-
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
65-
IF("${isSystemDir}" STREQUAL "-1")
66-
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
67-
ENDIF("${isSystemDir}" STREQUAL "-1")
68-
endif()
69-
70-
71-
########################################################################
72-
# Project definitions #
73-
########################################################################
74-
project(trex)
75-
set(TREX_MAJOR 0)
76-
set(TREX_MINOR 6)
77-
set(TREX_PATCH 5)
78-
set(TREX_RC 0)
79-
80-
# TREX script for CPack management
81-
include(trex_pack)
82-
83-
include_directories(
84-
${PROJECT_SOURCE_DIR}
85-
${CMAKE_CURRENT_BINARY_DIR}
86-
# Need this for config generated files
87-
${CMAKE_BINARY_DIR}/trex/utils
88-
)
38+
project(trex VERSION 0.7.0)
8939

9040
include(trex_requirements)
91-
include(trex_macros)
92-
93-
set(TREX_SHARED share/trex)
94-
include_directories(${CMAKE_BINARY_DIR})
9541

9642
########################################################################
9743
# TREX sub directories #
9844
########################################################################
99-
10045
# core libraries
10146
add_subdirectory(trex)
102-
trex_cfg(cfg ${TREX_SHARED})
10347

10448
# include extra/plugins
10549
add_subdirectory(extra)
10650

51+
configure_file(scripts/trex_init.bash.in ${CMAKE_CURRENT_BINARY_DIR}/trex_init.bash @ONLY)
52+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trex_init.bash DESTINATION shared/trex)
53+
10754
########################################################################
10855
# Finalize #
10956
########################################################################
110-
include(trex_finalize)
111-
57+
install(EXPORT trex NAMESPACE trex:: DESTINATION shared/trex/cmake/imports OPTIONAL)
58+
59+
include(CMakePackageConfigHelpers)
60+
61+
configure_package_config_file(cmake/trex-config.cmake.in
62+
"${CMAKE_CURRENT_BINARY_DIR}/trexConfig.cmake"
63+
INSTALL_DESTINATION shared/trex/cmake
64+
)
65+
write_basic_package_version_file(trexConfigVersion.cmake VERSION ${VERSION} COMPATIBILITY AnyNewerVersion)
66+
install(FILES
67+
"${CMAKE_CURRENT_BINARY_DIR}/trexConfig.cmake"
68+
"${CMAKE_CURRENT_BINARY_DIR}/trexConfigVersion.cmake"
69+
DESTINATION shared/trex/cmake
70+
)

cmake/trex-config.cmake.in

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,9 @@
3333
# POSSIBILITY OF SUCH DAMAGE. #
3434
#######################################################################
3535
# include directories used by trex libraries
36-
set(trex_INCLUDE_DIRS @TREX_INCS@ CACHE STRING "include paths for trex" FORCE)
37-
# flags required to use trex : mostly the ones related to c++11 support when enabled
38-
set(trex_CPPFLAGS @trex_FLAGS@ CACHE STRING "trex extra C++ flags" FORCE)
39-
40-
set(trex_VERSION @VERSION@)
36+
@PACKAGE_INIT@
4137

4238
get_filename_component(TREX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
4339
# Import trex libraries
44-
include(${TREX_CMAKE_DIR}/imports/trex-targets.cmake)
45-
# the set of core libraries targets
46-
set(trex_LIBRARIES @trex-core@ CACHE STRING "trex core libraries" FORCE)
47-
# the set of extra libraries (such as europa extensions, ros, ...)
48-
set(trex_extra_LIBRARIES @trex-extra@ CACHE STRING "trex extensions for plugins" FORCE)
40+
include(${TREX_CMAKE_DIR}/imports/trex.cmake)
4941

50-
# Note the plugin are not included ... should work on that later
51-
set(trex_python_LIBRARIES @trex-python@ CACHE STRING "trex python modules" FORCE)

cmake/trex_requirements.cmake

Lines changed: 9 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -41,193 +41,39 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
4141
set(LINK_NO_AS_NEEDED "-Wl,--no-as-needed")
4242
endif()
4343

44-
45-
4644
########################################################################
4745
# System libraries #
4846
########################################################################
4947
include(CheckLibraryExists)
5048

51-
check_library_exists(dl dlopen "" LIB_DL)
52-
if(LIB_DL)
53-
set(SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} dl)
54-
else(LIB_DL)
49+
check_library_exists(dl dlopen "" HAVE_DL)
50+
if(NOT HAVE_DL)
5551
message(FATAL_ERROR "TREX requires lib dl")
56-
endif(LIB_DL)
57-
58-
check_library_exists(pthread pthread_self "" LIB_PTHREAD)
59-
if(LIB_PTHREAD)
60-
set(SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} pthread)
61-
endif(LIB_PTHREAD)
62-
63-
check_library_exists(rt shm_unlink "" LIB_RT)
64-
if(LIB_RT)
65-
set(SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} rt)
66-
endif(LIB_RT)
67-
68-
########################################################################
69-
# Boost C++ general requirement
70-
########################################################################
71-
72-
#set(Boost_USE_STATIC_LIBS ON)
73-
#set(Boost_USE_MULTITHREADED ON)
74-
#set(Boost_USE_STATIC_RUNTIME OFF)
52+
endif(NOT HAVE_DL)
7553

76-
option(WITH_CPP11 "Compile with C++11 support" OFF)
54+
find_package(Boost 1.70 REQUIRED COMPONENTS
55+
system regex date_time program_options thread)
7756

78-
# The minimum requirement
79-
find_package(Boost 1.46.1 REQUIRED COMPONENTS
80-
system filesystem thread regex signals date_time program_options)
8157

8258
if(NOT Boost_FOUND)
8359
message(ERROR "Unable to find Boost (>=1.46.1) library")
8460
endif(NOT Boost_FOUND)
8561

86-
include_directories(${Boost_INCLUDE_DIRS})
87-
find_package(Boost COMPONENTS chrono)
88-
message(STATUS "Checking for Boost.Chrono: ${Boost_CHRONO_LIBRARY}")
89-
90-
91-
if(Boost_CHRONO_LIBRARY)
92-
set(CHRONO_LIB ${Boost_CHRONO_LIBRARY} CACHE PATH "Boost chrono library path" FORCE)
93-
else(Boost_CHRONO_LIBRARY)
94-
set(CHRONO_LIB "" CACHE PATH "Boost chrono not found" FORCE)
95-
if(NOT WITH_CPP11)
96-
message(FATAL_ERROR "Boost.Chrono was not found and WITH_CPP11 is false."
97-
"Try to enable WITH_CPP11 in order to find C++11 chrono implementation.")
98-
endif(NOT WITH_CPP11)
99-
endif(Boost_CHRONO_LIBRARY)
100-
101-
########################################################################
102-
# C++11 capabilities #
103-
########################################################################
104-
if(WITH_CPP11)
105-
include(${PROJECT_SOURCE_DIR}/cmake/cpp11/cpp11.cmake)
106-
107-
if(NOT CHRONO_LIB)
108-
cpp11_feature_detection(CHRONO)
109-
if(NOT CPP11_HAS_CHRONO)
110-
message(ERROR "Did not find required chrono support")
111-
endif(NOT CPP11_HAS_CHRONO)
112-
endif(NOT CHRONO_LIB)
113-
# Helpers to refine the code when cpp11 enabled
114-
cpp11_feature_detection(UNIQUE_PTR)
115-
cpp11_feature_detection(SHARED_PTR)
116-
cpp11_feature_detection(DELETED_FUNCTIONS)
117-
#cpp11_feature_detection(THREAD)
118-
119-
if(CPP11_ENABLED)
120-
set(boost_flags -I${Boost_INCLUDE_DIRS})
121-
# A simple date_time program : will fail to compile if boost
122-
# was linked to a non c++11 compatible standard library
123-
# this handle Clang that links against different lib*c++ depending
124-
# on c++11 flags
125-
cpp11_lib_support(Boost_DATE_TIME "#include <boost/date_time/posix_time/posix_time.hpp>
126-
#include <iostream>
127-
128-
using namespace boost::posix_time\;
129-
130-
int main(int argc, char *argv[]) {
131-
ptime today(second_clock::local_time())\;
132-
std::cout<<today<<std::endl\;
133-
return 0\;
134-
}" ${boost_flags} ${Boost_DATE_TIME_LIBRARY})
135-
136-
137-
if(NOT ${CPP11_SUPPORT_Boost_DATE_TIME})
138-
message(FATAL_ERROR " Boost.DATE_TIME library cannot be used with C++11")
139-
endif(NOT ${CPP11_SUPPORT_Boost_DATE_TIME})
140-
141-
cpp11_lib_support(Boost_PROGRAM_OPTIONS "#include <boost/program_options.hpp>
142-
#include <iostream>
143-
144-
namespace po=boost::program_options\;
145-
146-
namespace {
147-
po::options_description opt(\"Test:\")\;
148-
}
149-
150-
int main(int argc, char *argv[]) {
151-
opt.add_options()
152-
(\"help,h\", \"should print help\")
153-
(\"val,v\", po::value< std::vector<std::string> >(), \"A set of strings\")
154-
(\"int,i\", po::value<int>()->implicit_value(0), \"An integer\")\;
155-
156-
po::variables_map vals\;
157-
158-
try {
159-
po::store(po::command_line_parser(argc,argv).options(opt).run(), vals)\;
160-
po::notify(vals)\;
161-
} catch(po::error) {
162-
return 1\;
163-
}
164-
return 0\;
165-
}" ${boost_flags} ${Boost_PROGRAM_OPTIONS_LIBRARY})
166-
167-
# this test if boost/get_pointer defines get_pointer for std::shared_ptr
168-
if(CPP11_HAS_SHARED_PTR)
169-
file(WRITE ${CMAKE_BINARY_DIR}/boost_get_pointer_test.cc "#include <memory>
170-
#include <boost/get_pointer.hpp>
171-
172-
int main(int argv, char *argc[]) {
173-
std::shared_ptr<int> foo = std::make_shared<int>(0);
174-
return boost::get_pointer(foo)==foo.get()?0:1;
175-
}
176-
")
177-
try_compile(success
178-
${CMAKE_BINARY_DIR}
179-
${CMAKE_BINARY_DIR}/boost_get_pointer_test.cc
180-
COMPILE_DEFINITIONS ${CPP11_COMPILER_SWITCH} ${boost_flags}
181-
CMAKE_FLAGS
182-
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CPP11_link_flags}
183-
-DLINK_LIBRARIES:STRING=${LIBS}
184-
OUTPUT_VARIABLE OUT)
185-
set(CPP11_BOOST_GET_POINTER_STD ${success})
186-
if(NOT success)
187-
file(WRITE ${CMAKE_BINARY_DIR}/boost_get_pointer_test.out ${OUT})
188-
endif(NOT success)
189-
message(STATUS "Test if boost::get_pointer support std::shared_ptr: ${CPP11_BOOST_GET_POINTER_STD}")
190-
endif(CPP11_HAS_SHARED_PTR)
191-
192-
193-
if(NOT ${CPP11_SUPPORT_Boost_PROGRAM_OPTIONS})
194-
message(FATAL_ERROR " Boost.Program_Options library cannot be used with C++11")
195-
endif(NOT ${CPP11_SUPPORT_Boost_PROGRAM_OPTIONS})
196-
197-
add_definitions(${CPP11_COMPILER_SWITCH})
198-
# SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}
199-
# CACHE STRING "Flags used by the linker during the creation of dll's.")
200-
# set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${CPP11_LINK_FLAGS})
201-
# set(CMAKE_LINK_LIBRARY_FLAGS ${CMAKE_LINK_LIBRARY_FLAGS} ${CPP11_LINK_FLAGS})
202-
# message(STATUS "CPP11_LINK_FLAGS=${CPP11_LINK_FLAGS}")
203-
# message(STATUS "CMAKE_LINK_LIBRARY_FLAGS=${CMAKE_LINK_LIBRARY_FLAGS}")
204-
# # The xcode stuff
205-
# set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
206-
# set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
207-
endif(CPP11_ENABLED)
208-
else(WITH_CPP11)
209-
# ensure that cpp11 is not enabled
210-
set(CPP11_ENABLED FALSE)
211-
endif(WITH_CPP11)
212-
213-
message(STATUS "CPP11 enabled: ${CPP11_ENABLED}")
214-
message(STATUS "CHRONO_LIB: ${CHRONO_LIB}")
215-
21662
########################################################################
21763
# Europa #
21864
########################################################################
219-
22065
option(WITH_EUROPA "Enable Europa plugin." ON)
22166

222-
if(WITH_EUROPA)
67+
if(WITH_EUROPA)
22368
find_package(Europa
22469
COMPONENTS PlanDatabase ConstraintEngine TemporalNetwork Utils TinyXml
225-
NDDL RulesEngine Solvers System)
70+
NDDL RulesEngine Solvers System)
22671
if(NOT EUROPA_FOUND)
227-
message(FATAL_ERROR "Failed to find Europa while WITH_EUROPA is ON")
72+
message(FATAL_ERROR "Failed to find Europa while WITH_EUROPA is ON")
22873
endif(NOT EUROPA_FOUND)
22974
endif(WITH_EUROPA)
23075

76+
23177
########################################################################
23278
# Doxygen #
23379
########################################################################

extra/CMakeLists.txt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,24 @@
3535

3636
add_custom_target(plugins COMMENT "TREX plugins")
3737

38-
macro(trex_plugin name src)
39-
add_library(${name}_pg SHARED ${src} ${ARGN})
40-
add_dependencies(plugins ${name}_pg)
41-
install(TARGETS ${name}_pg DESTINATION ${TREX_SHARED}/plugins OPTIONAL
42-
EXPORT trex-plugins)
43-
trex_cfg(cfg ${TREX_SHARED})
44-
set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CFGS
45-
${CMAKE_CURRENT_BINARY_DIR})
46-
trex_lib(${name}_pg FALSE)
38+
macro(trex_plugin name)
39+
add_library(${name} SHARED)
40+
set_target_properties(${name} PROPERTIES OUTPUT_NAME "${name}_pg")
41+
add_dependencies(plugins ${name})
42+
install(
43+
TARGETS ${name}
44+
EXPORT trex_pg
45+
LIBRARY DESTINATION shared/trex/plugins
46+
)
4747
endmacro(trex_plugin)
4848

49-
# the directories where plugins are located
50-
add_subdirectory(Wt)
51-
add_subdirectory(REST)
52-
add_subdirectory(witre.old)
53-
# add_subdirectory(witre)
54-
add_subdirectory(europa)
49+
option(WITH_EUROPA "Enable Europa plugin." ON)
50+
51+
if(WITH_EUROPA)
52+
add_subdirectory(europa)
53+
endif(WITH_EUROPA)
5554

5655
# 3rd party plug-ins
5756
add_subdirectory(third_party)
5857

59-
# examples
60-
add_subdirectory(examples)
58+

0 commit comments

Comments
 (0)