Skip to content

Commit

Permalink
cmake: fix bug #1012: CMake issues with newer Xenomai custom installs.
Browse files Browse the repository at this point in the history
Addressed the various issues and ambiguous error reports one could have
when selecting the xenomai target.
Also fixed linking with the mqueue headers in Xenomai environments by
passing the flags from xeno-config directly.

Signed-off-by: Peter Soetens <[email protected]>
  • Loading branch information
Peter Soetens committed Dec 17, 2012
1 parent 2c830bf commit ccbaa7c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 20 deletions.
20 changes: 19 additions & 1 deletion config/FindXenomai.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
#
# CMake script for finding XENOMAI.
# CMake script for finding the XENOMAI native skin.
# If the optional XENOMAI_ROOT_DIR environment variable exists, header files and
# libraries will be searched in the XENOMAI_ROOT_DIR/include and XENOMAI_ROOT_DIR/lib
# directories, respectively. Otherwise the default CMake search process will be
Expand All @@ -21,6 +21,14 @@ if(NOT $ENV{XENOMAI_ROOT_DIR} STREQUAL "")
mark_as_advanced(XENOMAI_ROOT_DIR)
endif()

if ( Xenomai_FIND_QUIETLY )
set( XENOMAI_FIND_QUIETLY "QUIET")
endif()

if ( Xenomai_FIND_REQUIRED )
set( XENOMAI_FIND_REQUIRED "REQUIRED")
endif()

# Header files to find
set(header_NAME native/task.h)

Expand All @@ -31,16 +39,26 @@ set(XENOMAI_NATIVE_NAME native)
# Find headers and libraries
if(XENOMAI_ROOT_DIR)
# Use location specified by environment variable
find_program(XENOMAI_XENO_CONFIG NAMES xeno-config PATHS ${XENOMAI_ROOT_DIR}/bin NO_DEFAULT_PATH)
find_path(XENOMAI_INCLUDE_DIR NAMES ${header_NAME} PATHS ${XENOMAI_ROOT_DIR}/include PATH_SUFFIXES xenomai NO_DEFAULT_PATH)
find_library(XENOMAI_LIBRARY NAMES ${XENOMAI_NAME} PATHS ${XENOMAI_ROOT_DIR}/lib NO_DEFAULT_PATH)
find_library(XENOMAI_NATIVE_LIBRARY NAMES ${XENOMAI_NATIVE_NAME} PATHS ${XENOMAI_ROOT_DIR}/lib NO_DEFAULT_PATH)
else()
# Use default CMake search process
find_program(XENOMAI_XENO_CONFIG NAMES xeno-config )
find_path(XENOMAI_INCLUDE_DIR NAMES ${header_NAME} PATH_SUFFIXES xenomai )
find_library(XENOMAI_LIBRARY NAMES ${XENOMAI_NAME})
find_library(XENOMAI_NATIVE_LIBRARY NAMES ${XENOMAI_NATIVE_NAME})
endif()

if( XENOMAI_LIBRARY AND XENOMAI_INCLUDE_DIR AND NOT XENOMAI_XENO_CONFIG )
message(SEND_ERROR "Your Xenomai installation is broken: I can not determine Xenomai Native cflags/ldflags without xeno-config.")
else()
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --skin=native --ldflags OUTPUT_VARIABLE XENOMAI_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --skin=native --cflags OUTPUT_VARIABLE XENOMAI_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()


# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(XENOMAI_PROCESS_INCLUDES XENOMAI_INCLUDE_DIR)
Expand Down
28 changes: 18 additions & 10 deletions config/FindXenomaiPosix.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
#
# CMake script for finding XENOMAI.
# CMake script for finding the XENOMAI Posix skin.
# If the optional XENOMAI_ROOT_DIR environment variable exists, header files and
# libraries will be searched in the XENOMAI_ROOT_DIR/include and XENOMAI_ROOT_DIR/lib
# directories, respectively. Otherwise the default CMake search process will be
Expand All @@ -16,9 +16,17 @@
include(LibFindMacros)

# Get hint from environment variable (if any)
if(NOT $ENV{XENOMAI_POSIX_ROOT_DIR} STREQUAL "")
set(XENOMAI_POSIX_ROOT_DIR $ENV{XENOMAI_POSIX_ROOT_DIR} CACHE PATH "Xenomai Posix base directory location (optional, used for nonstandard installation paths)" FORCE)
mark_as_advanced(XENOMAI_POSIX_ROOT_DIR)
if(NOT $ENV{XENOMAI_ROOT_DIR} STREQUAL "")
set(XENOMAI_ROOT_DIR $ENV{XENOMAI_ROOT_DIR} CACHE PATH "Xenomai Posix base directory location (optional, used for nonstandard installation paths)" FORCE)
mark_as_advanced(XENOMAI_ROOT_DIR)
endif()

if ( XenomaiPosix_FIND_QUIETLY )
set( XENOMAI_POSIX_FIND_QUIETLY "QUIET")
endif()

if ( XenomaiPosix_FIND_REQUIRED )
set( XENOMAI_POSIX_FIND_REQUIRED "REQUIRED")
endif()

# Header files to find
Expand All @@ -28,11 +36,11 @@ set(header_NAME pthread.h)
set(XENOMAI_POSIX_NAME pthread_rt)

# Find headers and libraries
if(XENOMAI_POSIX_ROOT_DIR)
if(XENOMAI_ROOT_DIR)
# Use location specified by environment variable
find_program(XENOMAI_XENO_CONFIG NAMES xeno-config PATHS ${XENOMAI_POSIX_ROOT_DIR}/bin NO_DEFAULT_PATH)
find_path(XENOMAI_POSIX_INCLUDE_DIR NAMES ${header_NAME} PATHS ${XENOMAI_POSIX_ROOT_DIR}/include PATH_SUFFIXES xenomai/posix NO_DEFAULT_PATH)
find_library(XENOMAI_POSIX_LIBRARY NAMES ${XENOMAI_POSIX_NAME} PATHS ${XENOMAI_POSIX_ROOT_DIR}/lib NO_DEFAULT_PATH)
find_program(XENOMAI_XENO_CONFIG NAMES xeno-config PATHS ${XENOMAI_ROOT_DIR}/bin NO_DEFAULT_PATH)
find_path(XENOMAI_POSIX_INCLUDE_DIR NAMES ${header_NAME} PATHS ${XENOMAI_ROOT_DIR}/include PATH_SUFFIXES xenomai/posix NO_DEFAULT_PATH)
find_library(XENOMAI_POSIX_LIBRARY NAMES ${XENOMAI_POSIX_NAME} PATHS ${XENOMAI_ROOT_DIR}/lib NO_DEFAULT_PATH)
else()
# Use default CMake search process
find_program(XENOMAI_XENO_CONFIG NAMES xeno-config )
Expand All @@ -43,8 +51,8 @@ endif()
if( XENOMAI_POSIX_LIBRARY AND XENOMAI_POSIX_INCLUDE_DIR AND NOT XENOMAI_XENO_CONFIG )
message(SEND_ERROR "Your Xenomai installation is broken: I can not determine Xenomai POSIX cflags/ldflags without xeno-config.")
else()
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --posix-ldflags OUTPUT_VARIABLE XENOMAI_POSIX_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --posix-cflags OUTPUT_VARIABLE XENOMAI_POSIX_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --skin=posix --ldflags OUTPUT_VARIABLE XENOMAI_POSIX_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${XENOMAI_XENO_CONFIG} --skin=posix --cflags OUTPUT_VARIABLE XENOMAI_POSIX_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

# Set the include dir variables and the libraries and let libfind_process do the rest.
Expand Down
2 changes: 1 addition & 1 deletion config/LibFindMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ macro (libfind_process PREFIX)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use the ${PREFIX}_ROOT_DIR environment variable or ccmake to set the missing variables manually.")
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, set the ${PREFIX}_ROOT_DIR environment variable or use cmake to set the missing variables manually.")
else (${PREFIX}_FIND_REQUIRED) # NOTE: else case not included in original file
message (STATUS "Optional library ${PREFIX} NOT FOUND. If the library is already installed, use the ${PREFIX}_ROOT_DIR environment variable or ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
Expand Down
11 changes: 9 additions & 2 deletions config/check_depend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ endif(XERCES_FOUND)
message("Orocos target is ${OROCOS_TARGET}")
string(TOUPPER ${OROCOS_TARGET} OROCOS_TARGET_CAP)

if ( NOT ";lxrt;gnulinux;xenomai;macosx;win32;" MATCHES ".*;${OROCOS_TARGET};.*")
message( FATAL_ERROR "OROCOS_TARGET=${OROCOS_TARGET} is an unkown target. Please use one of lxrt;gnulinux;xenomai;macosx;win32.")
endif()

# Setup flags for RTAI/LXRT
if(OROCOS_TARGET STREQUAL "lxrt")
set(OROPKG_OS_LXRT TRUE CACHE INTERNAL "This variable is exported to the rtt-config.h file to expose our target choice to the code." FORCE)
Expand Down Expand Up @@ -144,10 +148,13 @@ if(OROCOS_TARGET STREQUAL "xenomai")
add_definitions( -Wall )

if(XENOMAI_FOUND)
list(APPEND OROCOS-RTT_USER_LINK_LIBS ${XENOMAI_LIBRARIES} ) # For libraries used in inline (fosi/template) code.
# Input for .pc and .cmake generated files:
list(APPEND OROCOS-RTT_INCLUDE_DIRS ${XENOMAI_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIRS})
list(APPEND OROCOS-RTT_LIBRARIES ${XENOMAI_LIBRARIES} ${PTHREAD_LIBRARIES} dl)
list(APPEND OROCOS-RTT_DEFINITIONS "OROCOS_TARGET=${OROCOS_TARGET}")
# Direct input only for .pc file:
list(APPEND RTT_USER_LDFLAGS ${XENOMAI_LDFLAGS} )
list(APPEND RTT_USER_CFLAGS ${XENOMAI_CFLAGS} )
if (XENOMAI_POSIX_FOUND)
set(MQ_LDFLAGS ${XENOMAI_POSIX_LDFLAGS} )
set(MQ_CFLAGS ${XENOMAI_POSIX_CFLAGS} )
Expand Down Expand Up @@ -261,7 +268,7 @@ else(OROCOS_TARGET STREQUAL "win32")
endif(OROCOS_TARGET STREQUAL "win32")

if( NOT OROCOS-RTT_DEFINITIONS )
message(FATAL_ERROR "No suitable OROCOS_TARGET selected. Use one of 'lxrt,xenomai,gnulinux,macosx,win32'")
message(FATAL_ERROR "No suitable OROCOS_TARGET found. Please check your setup or provide additional search paths to cmake.")
endif()

# The machine type is tested using compiler macros in rtt-config.h.in
Expand Down
2 changes: 1 addition & 1 deletion orocos-rtt.default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else()
set(OROCOS_TARGET gnulinux CACHE STRING "${DOC_STRING}")
endif()
endif()
message( "No OROCOS_TARGET environment variable detected. Using: ${OROCOS_TARGET}")
message( "No OROCOS_TARGET environment variable set. Using: ${OROCOS_TARGET}")
endif()

# Useful for Windows/MSVC builds, sets all libraries and executables in one place.
Expand Down
4 changes: 2 additions & 2 deletions rtt/orocos-rtt.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ includedir=${prefix}/include
Name: Orocos-RTT # human-readable name
Description: Open Robot Control Software: Real-Time Tookit # human-readable description
Version: @RTT_VERSION@
Libs: -L${libdir} -lorocos-rtt-@OROCOS_TARGET@ @RTT_USER_LINK_LIBS@ # If some RTT headers include inline calls to other libraries, we need to specify these here too.
Libs: -L${libdir} -lorocos-rtt-@OROCOS_TARGET@ @RTT_USER_LINK_LIBS@ @RTT_USER_LDFLAGS@ # If some RTT headers include inline calls to other libraries, we need to specify these here too.
Libs.private: @RTT_LINKFLAGS@
Cflags: -I${includedir} @RTT_DEFINES@ @RTT_CFLAGS@
Cflags: -I${includedir} @RTT_DEFINES@ @RTT_CFLAGS@ @RTT_USER_CFLAGS@
6 changes: 3 additions & 3 deletions rtt/transports/mqueue/orocos-rtt-mqueue.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Name: Orocos-RTT-MQUEUE # human-readable nam
Description: Open Robot Control Software: Real-Time Tookit # human-readable description
Requires: orocos-rtt-@OROCOS_TARGET@
Version: @RTT_VERSION@
Libs: -L${libdir} -lorocos-rtt-mqueue-@OROCOS_TARGET@
Libs.private: @RTT_MQUEUE_LINKFLAGS@
Cflags: -I${includedir}/rtt/mqueue @RTT_MQUEUE_DEFINES@ @RTT_MQUEUE_CFLAGS@
Libs: -L${libdir} -lorocos-rtt-mqueue-@OROCOS_TARGET@ @MQ_LDFLAGS@
Libs.private:
Cflags: -I${includedir}/rtt/mqueue @MQ_CFLAGS@

0 comments on commit ccbaa7c

Please sign in to comment.