cmake_minimum_required(VERSION 3.16)
set(Geant4_DIR D:/Geant4/dist/lib/Geant4-11.0.1)

project(DESCSS)

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()

include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)

file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h)

add_executable(DESCSS main.cpp ${sources} ${headers})
target_link_libraries(DESCSS ${Geant4_LIBRARIES})

set(DESCSS_SCRIPTS
    vis.mac
    assets/model.txt
)

foreach(_script ${DESCSS_SCRIPTS})
    configure_file(
        ${PROJECT_SOURCE_DIR}/${_script}
        ${PROJECT_BINARY_DIR}/Release/${_script}
        COPYONLY
    )
endforeach()

install(TARGETS DESCSS DESTINATION bin)
