eCos.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # support for eCos http://ecos.sourceware.org
  2. # Guard against multiple inclusion, which e.g. leads to multiple calls to add_definition() #12987
  3. if(__ECOS_CMAKE_INCLUDED)
  4. return()
  5. endif()
  6. set(__ECOS_CMAKE_INCLUDED TRUE)
  7. set(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic
  8. set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "") # -shared
  9. set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
  10. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
  11. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
  12. set(CMAKE_LINK_LIBRARY_SUFFIX "")
  13. set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
  14. set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
  15. set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
  16. set(CMAKE_SHARED_LIBRARY_SUFFIX ".a") # .a
  17. set(CMAKE_EXECUTABLE_SUFFIX ".elf") # same suffix as if built using UseEcos.cmake
  18. set(CMAKE_DL_LIBS "" )
  19. set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
  20. set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
  21. 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()
  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()
  30. # find eCos system files
  31. find_path(ECOS_SYSTEM_CONFIG_HEADER_PATH NAMES pkgconf/system.h)
  32. find_library(ECOS_SYSTEM_TARGET_LIBRARY NAMES libtarget.a)
  33. if(NOT ECOS_SYSTEM_CONFIG_HEADER_PATH)
  34. message(FATAL_ERROR "Could not find eCos pkgconf/system.h. Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.")
  35. endif()
  36. if(NOT ECOS_SYSTEM_TARGET_LIBRARY)
  37. message(FATAL_ERROR "Could not find eCos \"libtarget.a\". Build eCos first and set up CMAKE_FIND_ROOT_PATH correctly.")
  38. endif()
  39. get_filename_component(ECOS_LIBTARGET_DIRECTORY "${ECOS_SYSTEM_TARGET_LIBRARY}" PATH)
  40. include_directories(${ECOS_SYSTEM_CONFIG_HEADER_PATH})
  41. add_definitions(-D__ECOS__=1 -D__ECOS=1)
  42. # special link commands for eCos executables
  43. 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>")
  44. 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>")
  45. # eCos doesn't support shared libs
  46. set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
  47. set(CMAKE_CXX_LINK_SHARED_LIBRARY )
  48. set(CMAKE_CXX_LINK_MODULE_LIBRARY )
  49. set(CMAKE_C_LINK_SHARED_LIBRARY )
  50. set(CMAKE_C_LINK_MODULE_LIBRARY )