ENH: fix advanced bug
[cmake.git] / Modules / Platform / eCos.cmake
blobf0881c0bbc3ed2ecbddb6d8f3511448c8f3485a5
1 # support for eCos http://ecos.sourceware.org
2 SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")            # -pic 
3 SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "")       # -shared
4 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")         # +s, flag for exe link to use shared lib
5 SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")       # -rpath
6 SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "")   # : or empty
8 SET(CMAKE_LINK_LIBRARY_SUFFIX "")
9 SET(CMAKE_STATIC_LIBRARY_PREFIX "lib")
10 SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
11 SET(CMAKE_SHARED_LIBRARY_PREFIX "lib")          # lib
12 SET(CMAKE_SHARED_LIBRARY_SUFFIX ".a")           # .a
13 SET(CMAKE_EXECUTABLE_SUFFIX ".elf")             # same suffix as if built using UseEcos.cmake
14 SET(CMAKE_DL_LIBS "" )
16 SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
17 SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
20 INCLUDE(Platform/UnixPaths)
22 # eCos can be built only with gcc
23 GET_PROPERTY(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
24 IF(CMAKE_C_COMPILER AND NOT  "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC)
25   MESSAGE(FATAL_ERROR "GNU gcc is required for eCos")
26 ENDIF(CMAKE_C_COMPILER AND NOT  "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC)
27 IF(CMAKE_CXX_COMPILER AND NOT  "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC)
28   MESSAGE(FATAL_ERROR "GNU g++ is required for eCos")
29 ENDIF(CMAKE_CXX_COMPILER AND NOT  "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC)
31 # find eCos system files
32 FIND_PATH(ECOS_SYSTEM_CONFIG_HEADER_PATH NAMES pkgconf/system.h)
33 FIND_LIBRARY(ECOS_SYSTEM_TARGET_LIBRARY NAMES libtarget.a)
35 IF(NOT ECOS_SYSTEM_CONFIG_HEADER_PATH)
36   MESSAGE(FATAL_ERROR "Could not find eCos pkgconf/system.h. Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.")
37 ENDIF(NOT ECOS_SYSTEM_CONFIG_HEADER_PATH)
39 IF(NOT ECOS_SYSTEM_TARGET_LIBRARY)
40   MESSAGE(FATAL_ERROR "Could not find eCos \"libtarget.a\". Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.")
41 ENDIF(NOT ECOS_SYSTEM_TARGET_LIBRARY)
43 GET_FILENAME_COMPONENT(ECOS_LIBTARGET_DIRECTORY "${ECOS_SYSTEM_TARGET_LIBRARY}" PATH)
44 INCLUDE_DIRECTORIES(${ECOS_SYSTEM_CONFIG_HEADER_PATH})
45 ADD_DEFINITIONS(-D__ECOS__=1 -D__ECOS=1)
47 # special link commands for eCos executables
48 SET(CMAKE_CXX_LINK_EXECUTABLE  "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld  <LINK_LIBRARIES>")
49 SET(CMAKE_C_LINK_EXECUTABLE    "<CMAKE_C_COMPILER>   <FLAGS> <CMAKE_C_LINK_FLAGS>   <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld  <LINK_LIBRARIES>")
51 # eCos doesn't support shared libs
52 SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
54 SET(CMAKE_CXX_LINK_SHARED_LIBRARY )
55 SET(CMAKE_CXX_LINK_MODULE_LIBRARY )
56 SET(CMAKE_C_LINK_SHARED_LIBRARY )
57 SET(CMAKE_C_LINK_MODULE_LIBRARY )