From 5c7ce8130048cd1820341fc04b42478ea7aa0919 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 22 Feb 2019 23:26:32 -0600 Subject: [PATCH] Use CXX_STANDARD property to set -std flag. Get rid of UNIX define --- CMakeLists.txt | 19 ++++++++++--------- src/progress_bar.cpp | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19f98c800..cb92be848 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) -list(APPEND cxxflags -std=c++14 -O2) +list(APPEND cxxflags -O2) if(debug) list(REMOVE_ITEM cxxflags -O2) list(APPEND cxxflags -g -O0) @@ -202,15 +202,14 @@ add_library(libopenmc SHARED src/plot.cpp src/position.cpp src/progress_bar.cpp - src/urr.cpp src/random_lcg.cpp src/reaction.cpp src/reaction_product.cpp + src/scattdata.cpp src/secondary_correlated.cpp src/secondary_kalbach.cpp src/secondary_nbody.cpp src/secondary_uncorrelated.cpp - src/scattdata.cpp src/settings.cpp src/simulation.cpp src/source.cpp @@ -246,14 +245,14 @@ add_library(libopenmc SHARED src/timer.cpp src/thermal.cpp src/track_output.cpp + src/urr.cpp src/volume_calc.cpp src/wmp.cpp src/xml_interface.cpp src/xsdata.cpp) set_target_properties(libopenmc PROPERTIES - OUTPUT_NAME openmc - LINKER_LANGUAGE CXX) + OUTPUT_NAME openmc) target_include_directories(libopenmc PUBLIC include @@ -263,10 +262,6 @@ target_include_directories(libopenmc target_compile_options(libopenmc PRIVATE ${cxxflags}) target_compile_definitions(libopenmc PRIVATE -DMAX_COORD=${maxcoord}) -if (UNIX) - # Used in progress_header.F90 for calling check_isatty - target_compile_definitions(libopenmc PRIVATE -DUNIX) -endif() if (HDF5_IS_PARALLEL) target_compile_definitions(libopenmc PRIVATE -DPHDF5) endif() @@ -302,6 +297,12 @@ add_executable(openmc src/main.cpp) target_compile_options(openmc PRIVATE ${cxxflags}) target_link_libraries(openmc libopenmc) +# Ensure C++14 standard is used. Starting with CMake 3.8, another way this could +# be done is using the cxx_std_14 compiler feature. +set_target_properties( + openmc libopenmc faddeeva pugixml + PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF) + #=============================================================================== # Python package #=============================================================================== diff --git a/src/progress_bar.cpp b/src/progress_bar.cpp index 7917f9ffd..ab77c72f9 100644 --- a/src/progress_bar.cpp +++ b/src/progress_bar.cpp @@ -5,14 +5,14 @@ #include #include -#ifdef UNIX +#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) #include #endif #define BAR_WIDTH 72 bool is_terminal() { -#ifdef UNIX +#ifdef _POSIX_VERSION return isatty(STDOUT_FILENO) != 0; #else return false;