Skip to content

Commit

Permalink
Merge pull request #47 from JohanMabille/upgrade
Browse files Browse the repository at this point in the history
Upgraded to xproperty 0.12 and nlohmann_json 3.11.3
  • Loading branch information
JohanMabille authored Jun 4, 2024
2 parents 81cd0c2 + 01d1e97 commit 5030f60
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 110 deletions.
20 changes: 6 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# The full license is in the file LICENSE, distributed with this software.

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)
project(xvega)

set(XVEGA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down Expand Up @@ -54,11 +54,11 @@ set(xtl_REQUIRED_VERSION 0.7.0)
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found xtl: ${xtl_INCLUDE_DIRS}/xtl")

set(xproperty_REQUIRED_VERSION 0.11.0)
set(xproperty_REQUIRED_VERSION 0.12.0)
find_package(xproperty ${xproperty_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found xproperty: ${xproperty_INCLUDE_DIRS}/xproperty")

set(nlohmann_json_REQUIRED_VERSION 3.7.3)
set(nlohmann_json_REQUIRED_VERSION 3.11.3)
find_package(nlohmann_json ${nlohmann_json_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found nlohmann_json: ${nlohmann_json_INCLUDE_DIRS}/nlohmann_json")

Expand Down Expand Up @@ -348,14 +348,15 @@ set(XVEGA_SOURCES
# Targets and link - Macros
# =========================

include(CheckCXXCompilerFlag)

set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")

macro(xvega_set_common_options target_name)
set_target_properties(${target_name} PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED 17)

target_compile_features(${target_name} PRIVATE cxx_std_17)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Intel")
Expand All @@ -375,15 +376,6 @@ macro(xvega_set_common_options target_name)
target_compile_options(${target_name} PUBLIC -march=native)
endif ()
endif ()

# C++14 flag
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
if (HAS_CPP14_FLAG)
target_compile_features(${target_name} PRIVATE cxx_std_17)
else ()
message(FATAL_ERROR "Unsupported compiler -- xvega requires C++14 support!")
endif ()

endif ()

if (APPLE)
Expand Down
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- ninja
# host Dependencies
- xtl=0.7.0
- xproperty=0.11.0
- nlohmann_json=3.11.2
- xproperty=0.12.0
- nlohmann_json=3.11.3
# Test dependencies
- doctest
33 changes: 6 additions & 27 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# The full license is in the file LICENSE, distributed with this software.

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(xvega-test)
Expand All @@ -20,29 +20,10 @@ else()
message(STATUS "Tests build type is ${CMAKE_BUILD_TYPE}")
endif()

include(CheckCXXCompilerFlag)

string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)

include(set_compiler_flag.cmake)

set_compiler_flag(
_cxx_std_flag CXX REQUIRED
"-std=c++14" # this should work with GNU, Intel, PGI
"/std:c++14" # this should work with MSVC
)
message(STATUS "Building with C++14")

if(NOT _cxx_std_flag)
message(FATAL_ERROR "xvega needs a C++14-compliant compiler.")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32))
CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported)
if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wunused-variable -ftemplate-backtrace-limit=0")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /MP /bigobj")
Expand All @@ -51,14 +32,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT WIN32)
CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported)
if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wunused-variable")
else() # We are using clang-cl
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
Expand All @@ -85,6 +62,7 @@ foreach(filename IN LISTS XVEGA_TESTS)
string(REPLACE ".cpp" "" targetname ${filename})
add_executable(${targetname} ${filename} main.cpp ${XVEGA_HEADERS})
target_include_directories(${targetname} PRIVATE ${XVEGA_INCLUDE_DIR})
target_compile_features(${targetname} PRIVATE cxx_std_17)
target_link_libraries(${targetname} PRIVATE xvega doctest::doctest Threads::Threads)
add_custom_target(
x${targetname}
Expand All @@ -95,6 +73,7 @@ endforeach()
add_executable(test_xvega_lib ${XVEGA_TESTS} ${XVEGA_HEADERS})

target_include_directories(test_xvega_lib PRIVATE ${XVEGA_INCLUDE_DIR})
target_compile_features(test_xvega_lib PRIVATE cxx_std_17)
target_link_libraries(test_xvega_lib PRIVATE xvega doctest::doctest Threads::Threads)

add_custom_target(xtest COMMAND test_xvega_lib DEPENDS test_xvega_lib)
66 changes: 0 additions & 66 deletions test/set_compiler_flag.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion xvegaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

include(CMakeFindDependencyMacro)
find_dependency(xtl @xtl_REQUIRED_VERSION@)
find_dependency(nlohmann_json @nlohmann_json_REQUIRED_VERSION@)
find_dependency(nlohmann_json @nlohmann_json_VERSION@ EXACT)
find_dependency(xproperty @xproperty_REQUIRED_VERSION@)

if(NOT TARGET @PROJECT_NAME@)
Expand Down

0 comments on commit 5030f60

Please sign in to comment.