get_filename_component(CURRENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
list(APPEND CMAKE_MODULE_PATH ${CURRENT_CMAKE_DIR})

#include(CMakeFindDependencyMacro) # use find_package instead

# NOTE: some packages may be optional (platform-specific, etc.)
# find_package(... REQUIRED)
find_package(chromium_base REQUIRED)
# see https://doc.magnum.graphics/corrade/corrade-cmake.html#corrade-cmake-subproject
find_package(Corrade REQUIRED PluginManager)
find_package(Cling)
find_package(flexlib)
find_package(flextool)

list(REMOVE_AT CMAKE_MODULE_PATH -1)

if(NOT TARGET CONAN_PKG::<%= projectName %>)
  message(FATAL_ERROR "Use <%= projectName %> from conan")
endif()
set(<%= projectName %>_LIB
  CONAN_PKG::<%= projectName %>
)
set(<%= projectName %>_FILE
  ${CONAN_<%= projectName %>_ROOT}/lib/<%= projectName %>${CMAKE_SHARED_LIBRARY_SUFFIX}
)
# conan package has '/include' dir
set(<%= projectName %>_HEADER_DIR
  ${CONAN_<%= projectName %>_ROOT}/include
)
if(TARGET <%= projectName %>)
  # name of created target
  set(<%= projectName %>_LIB
    <%= projectName %>
  )
  # no '/include' dir on local build
  set(<%= projectName %>_HEADER_DIR
    ${CONAN_<%= projectName %>_ROOT}
  )
  # plugin file
  get_property(<%= projectName %>_LIBRARY_OUTPUT_DIRECTORY
    TARGET ${<%= projectName %>_LIB}
    PROPERTY LIBRARY_OUTPUT_DIRECTORY)
  message(STATUS "<%= projectName %>_LIBRARY_OUTPUT_DIRECTORY == ${<%= projectName %>_LIBRARY_OUTPUT_DIRECTORY}")
  set(<%= projectName %>_FILE
    ${<%= projectName %>_LIBRARY_OUTPUT_DIRECTORY}/<%= projectName %>${CMAKE_SHARED_LIBRARY_SUFFIX}
  )
endif()

if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cmake/<%= projectName %>-config.cmake")
  # uses Config.cmake or a -config.cmake file
  # see https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file
  # BELOW MUST BE EQUAL TO find_package(... CONFIG REQUIRED)
  # NOTE: find_package(CONFIG) not supported with EMSCRIPTEN, so use include()
  include(${CMAKE_CURRENT_LIST_DIR}/cmake/<%= projectName %>-config.cmake)
endif()

message(STATUS "<%= projectName %>_HEADER_DIR=${<%= projectName %>_HEADER_DIR}")
