diff --git a/Modules/Platform/eCos.cmake b/Modules/Platform/eCos.cmake index e7709ccea..f0881c0bb 100644 --- a/Modules/Platform/eCos.cmake +++ b/Modules/Platform/eCos.cmake @@ -20,27 +20,29 @@ SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") INCLUDE(Platform/UnixPaths) # eCos can be built only with gcc -IF(CMAKE_C_COMPILER AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "GNU") +GET_PROPERTY(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) +IF(CMAKE_C_COMPILER AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) MESSAGE(FATAL_ERROR "GNU gcc is required for eCos") -ENDIF(CMAKE_C_COMPILER AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "GNU") -IF(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - MESSAGE(FATAL_ERROR "GNU gcc is required for eCos") -ENDIF(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") +ENDIF(CMAKE_C_COMPILER AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) +IF(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) + MESSAGE(FATAL_ERROR "GNU g++ is required for eCos") +ENDIF(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) -# this is a header which is part of every eCos "installation" -# it would be better to search for libtarget.a, but this isn't possible -# at this point in the setup process, since CMAKE_SIZEOF_VOID_P is still -# unknown, which is used in FIND_LIBRARY() +# find eCos system files FIND_PATH(ECOS_SYSTEM_CONFIG_HEADER_PATH NAMES pkgconf/system.h) +FIND_LIBRARY(ECOS_SYSTEM_TARGET_LIBRARY NAMES libtarget.a) IF(NOT ECOS_SYSTEM_CONFIG_HEADER_PATH) MESSAGE(FATAL_ERROR "Could not find eCos pkgconf/system.h. Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.") ENDIF(NOT ECOS_SYSTEM_CONFIG_HEADER_PATH) -GET_FILENAME_COMPONENT(ECOS_LIBTARGET_DIRECTORY "${ECOS_SYSTEM_CONFIG_HEADER_PATH}" PATH) +IF(NOT ECOS_SYSTEM_TARGET_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find eCos \"libtarget.a\". Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.") +ENDIF(NOT ECOS_SYSTEM_TARGET_LIBRARY) + +GET_FILENAME_COMPONENT(ECOS_LIBTARGET_DIRECTORY "${ECOS_SYSTEM_TARGET_LIBRARY}" PATH) INCLUDE_DIRECTORIES(${ECOS_SYSTEM_CONFIG_HEADER_PATH}) ADD_DEFINITIONS(-D__ECOS__=1 -D__ECOS=1) -SET(ECOS_LIBTARGET_DIRECTORY "${ECOS_LIBTARGET_DIRECTORY}/lib") # special link commands for eCos executables SET(CMAKE_CXX_LINK_EXECUTABLE " -o -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld ")