Hi,
I am trying to build a project with has ROOT dependencies (I believe because output is being written to a .root file).
When trying to build the project, I get many The C++ standard in this build does not match ROOT configuration (201703L)
errors.
I compiled Geant4 and ROOT from source using Visual Studio 17. At the time I did not specify any standard, so assuming it defaults to some sort of ‘latest’ I don’t understand why there would be a difference between them.
Similarly, I don’t specify a standard when I am building the project, so I am unsure how to proceed. Any help would be brilliant.
In case it is helpful, I have included the cmake file for the project build:
#cmake_minimum_required(VERSION 2.8)
#add_executable(SBS SBS.cc)
#target_link_libraries(SBS ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(MuSim)
find_package(Geant4 REQUIRED)
##
## Get the ROOT config
set(ROOT_DIR "C:/path/to/root_v6.28/cmake")
find_package(ROOT "6.27" REQUIRED)
set(INC_ROOT ${ROOT_INCLUDE_DIRS})
set(LIB_ROOT ${ROOT_LIBRARY_DIR})
#include_directories(${Geant4_INCLUDE_DIRS} ${INC_ROOT})
add_definitions(${Geant4_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${Geant4_CXX_FLAGS}")
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(GEANT4_INSTALL_DATA "Data" ON)
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/objects/include ${INC_ROOT})
link_directories(${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/objects/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh ${PROJECT_SOURCE_DIR}/objects/*.hh)
#file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
#file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cc ${sources} ${headers})
target_link_libraries(${PROJECT_NAME} ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS ${PROJECT_NAME} DESTINATION bin)