diff --git a/Drv/CMakeLists.txt b/Drv/CMakeLists.txt index 287fd1f2e1..0419ea2d70 100644 --- a/Drv/CMakeLists.txt +++ b/Drv/CMakeLists.txt @@ -15,12 +15,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxSpiDriver/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxI2cDriver/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StreamCrossover/") -# IP Socket is only supported for Linux, Darwin, VxWorks -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "VxWorks") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ip/") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpClient/") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpServer/") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Udp/") -else() - message(STATUS "Cannot use IP sockets with platform ${CMAKE_SYSTEM_NAME}. Skipping.") -endif() +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ip/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpClient/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpServer/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Udp/") diff --git a/Drv/Ip/CMakeLists.txt b/Drv/Ip/CMakeLists.txt index aea50f3317..374c1b0a94 100644 --- a/Drv/Ip/CMakeLists.txt +++ b/Drv/Ip/CMakeLists.txt @@ -5,6 +5,8 @@ # MOD_DEPS: (optional) module dependencies # #### +restrict_platforms(Posix) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/IpSocket.cpp" "${CMAKE_CURRENT_LIST_DIR}/TcpClientSocket.cpp" diff --git a/Drv/TcpClient/CMakeLists.txt b/Drv/TcpClient/CMakeLists.txt index 651dab2d35..508f3115d2 100644 --- a/Drv/TcpClient/CMakeLists.txt +++ b/Drv/TcpClient/CMakeLists.txt @@ -5,6 +5,8 @@ # MOD_DEPS: (optional) module dependencies # #### +restrict_platforms(Posix) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp" "${CMAKE_CURRENT_LIST_DIR}/TcpClientComponentImpl.cpp" diff --git a/Drv/TcpServer/CMakeLists.txt b/Drv/TcpServer/CMakeLists.txt index b7ef7cafc1..fa01088ead 100644 --- a/Drv/TcpServer/CMakeLists.txt +++ b/Drv/TcpServer/CMakeLists.txt @@ -5,6 +5,8 @@ # MOD_DEPS: (optional) module dependencies # #### +restrict_platforms(Posix) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp" "${CMAKE_CURRENT_LIST_DIR}/TcpServerComponentImpl.cpp" diff --git a/Drv/Udp/CMakeLists.txt b/Drv/Udp/CMakeLists.txt index 13357ebdc8..d6c6cc8071 100644 --- a/Drv/Udp/CMakeLists.txt +++ b/Drv/Udp/CMakeLists.txt @@ -5,6 +5,8 @@ # MOD_DEPS: (optional) module dependencies # #### +restrict_platforms(Posix) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Udp.fpp" "${CMAKE_CURRENT_LIST_DIR}/UdpComponentImpl.cpp" diff --git a/Os/Posix/CMakeLists.txt b/Os/Posix/CMakeLists.txt index 364a8784b9..8babf771b9 100644 --- a/Os/Posix/CMakeLists.txt +++ b/Os/Posix/CMakeLists.txt @@ -5,7 +5,7 @@ # MOD_DEPS: (optional) module dependencies # #### -restrict_platforms(Linux Darwin) +restrict_platforms(Posix) add_custom_target("${FPRIME_CURRENT_MODULE}") set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/File.cpp" diff --git a/Svc/CMakeLists.txt b/Svc/CMakeLists.txt index 7e5148c125..cf3195e8c1 100644 --- a/Svc/CMakeLists.txt +++ b/Svc/CMakeLists.txt @@ -53,7 +53,5 @@ if (FPRIME_ENABLE_TEXT_LOGGERS) add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ActiveTextLogger/") endif() -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/") - add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/") -endif() +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/") diff --git a/Svc/LinuxTimer/CMakeLists.txt b/Svc/LinuxTimer/CMakeLists.txt index 5462eaee08..1a1547f8eb 100644 --- a/Svc/LinuxTimer/CMakeLists.txt +++ b/Svc/LinuxTimer/CMakeLists.txt @@ -5,6 +5,7 @@ # MOD_DEPS: (optional) module dependencies # #### +restrict_platforms(Linux Darwin) if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") diff --git a/Svc/PosixTime/CMakeLists.txt b/Svc/PosixTime/CMakeLists.txt index d23980f5f6..a2103272b5 100644 --- a/Svc/PosixTime/CMakeLists.txt +++ b/Svc/PosixTime/CMakeLists.txt @@ -6,6 +6,8 @@ # # Note: using PROJECT_NAME as EXECUTABLE_NAME #### +restrict_platforms(Posix) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/PosixTime.fpp" "${CMAKE_CURRENT_LIST_DIR}/PosixTime.cpp" diff --git a/cmake/API.cmake b/cmake/API.cmake index 6b06a211a5..00ae3dba76 100644 --- a/cmake/API.cmake +++ b/cmake/API.cmake @@ -31,7 +31,17 @@ set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST ##### macro(restrict_platforms) set(__CHECKER ${ARGN}) - if (NOT FPRIME_TOOLCHAIN_NAME IN_LIST __CHECKER AND NOT FPRIME_PLATFORM IN_LIST __CHECKER) + + # Each of these empty if blocks are the valid-case, that is, the platform is supported. + # However, the reason why this is necessary is that this function is a macro and not a function. + # Macros copy-paste the code into the calling context. Thus, all these valid cases want to avoid calling return. + # The return call in the else block returns from the calling context (i.e. a restricted CMakeList.txt will + # return and not process the component setup). We do not want this return when the platform is allowed. + + if (FPRIME_TOOLCHAIN_NAME IN_LIST __CHECKER) + elseif(FPRIME_PLATFORM IN_LIST __CHECKER) + elseif("Posix" IN_LIST __CHECKER AND FPRIME_USE_POSIX) + else() get_module_name("${CMAKE_CURRENT_LIST_DIR}") message(STATUS "Neither toolchain ${FPRIME_TOOLCHAIN_NAME} nor platform ${FPRIME_PLATFORM} supported for module ${MODULE_NAME}") append_list_property("${MODULE_NAME}" GLOBAL PROPERTY RESTRICTED_TARGETS)