Revision: 75712
          http://sourceforge.net/p/brlcad/code/75712
Author:   starseeker
Date:     2020-05-06 23:34:47 +0000 (Wed, 06 May 2020)
Log Message:
-----------
Add an iostream C++ test for the POSIX_C_SOURCE and XOPEN_SOURCE definitions 
for OpenBSD.

Modified Paths:
--------------
    brlcad/trunk/CMakeLists.txt

Modified: brlcad/trunk/CMakeLists.txt
===================================================================
--- brlcad/trunk/CMakeLists.txt 2020-05-06 23:04:29 UTC (rev 75711)
+++ brlcad/trunk/CMakeLists.txt 2020-05-06 23:34:47 UTC (rev 75712)
@@ -897,9 +897,36 @@
 endif(NOT DEFINED CMAKE_CXX_FLAGS_DEFAULT)
 mark_as_advanced(CMAKE_CXX_FLAGS_DEFAULT)
 
-# TODO - OpenBSD 6.6 doesn't tolerate these flags when using #include 
<iostream>
-set(API_FLAGS "-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700")
+# OpenBSD 6.6 doesn't tolerate these flags when using #include <iostream>,
+# so we have to test
+include(CheckCXXSourceRuns)
+include(CMakePushCheckState)
+function(BRLCAD_API_FLAG AFLAG AFLAGS)
+  set(CHECK_API_FLAG_SRC "
+#include <iostream>
+int main(int ac, char *av[])
+{
+  if (ac > 0 && av)
+    std::cout << \"hello\";
+  return 0;
+}
+")
+    string(TOUPPER "${AFLAG}" UAFLAG)
+    string(REPLACE "-" "_" AFLAGVAR "${UAFLAG}")
+    string(REPLACE "=" "_" AFLAGVAR "${AFLAGVAR}")
+    cmake_push_check_state()
+    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${C_STANDARD_FLAGS} 
${AFLAG}")
+    check_cxx_source_runs("${CHECK_API_FLAG_SRC}" WORKING_${AFLAGVAR})
+    cmake_pop_check_state()
+    if(WORKING_${AFLAGVAR})
+      set(${AFLAGS} "${${AFLAGS}} ${AFLAG}" PARENT_SCOPE)
+    endif(WORKING_${AFLAGVAR})
+endfunction(BRLCAD_API_FLAG)
 
+set(API_FLAGS)
+BRLCAD_API_FLAG("-D_POSIX_C_SOURCE=200809L" API_FLAGS)
+BRLCAD_API_FLAG("-D_XOPEN_SOURCE=700" API_FLAGS)
+
 # C
 unset(C_STANDARD_FLAGS)
 set(CMAKE_C_EXTENSIONS OFF)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to