# example main
add_executable(siscone_main options.cpp main.cpp)
target_link_libraries(siscone_main PUBLIC siscone)

# example area
add_executable(siscone_area options.cpp area.cpp)
target_link_libraries(siscone_area PUBLIC siscone)

# example test
add_executable(siscone_test options.cpp test.cpp)
target_link_libraries(siscone_test PUBLIC siscone)

# example times
add_executable(times options.cpp times.cpp)
target_link_libraries(times PUBLIC siscone)

# example sample
add_executable(sample options.cpp sample.cpp)
target_link_libraries(sample PUBLIC siscone)

# example spherical
add_executable(spherical options.cpp spherical.cpp)
target_link_libraries(spherical PUBLIC siscone_spherical)


if(MSVC)
  find_package(getopt CONFIG QUIET)

  # first try newer getopt search, and if that fails, try the
  # unofficial-getopt-win32 package
  if(getopt_FOUND)
    set(GETOPT_LIB
      $<IF:$<TARGET_EXISTS:getopt::getopt_shared>,
        getopt::getopt_shared,
        getopt::getopt_static>)
  else()
    find_package(unofficial-getopt-win32 REQUIRED)
    set(GETOPT_LIB unofficial::getopt-win32::getopt)
  endif()

  foreach(t siscone_main siscone_area siscone_test times sample spherical)
    target_compile_definitions(${t} PUBLIC _CRT_SECURE_NO_WARNINGS)
    target_link_libraries(${t} PRIVATE ${GETOPT_LIB})
  endforeach()
endif()

