2021-03-06 23:14:48 +08:00
|
|
|
# # # # sol2
|
2017-12-20 17:58:32 +08:00
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
2022-06-25 16:00:53 +08:00
|
|
|
# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors
|
2017-12-20 17:58:32 +08:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
# this software and associated documentation files (the "Software"), to deal in
|
|
|
|
# the Software without restriction, including without limitation the rights to
|
|
|
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
# subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2021-03-06 23:14:48 +08:00
|
|
|
# # # sol2 Examples
|
2017-12-20 17:58:32 +08:00
|
|
|
|
2021-05-07 06:44:25 +08:00
|
|
|
function(sol2_add_example_properties target-name)
|
|
|
|
target_link_libraries(${target-name}
|
|
|
|
PUBLIC Threads::Threads ${LUA_LIBRARIES} ${CMAKE_DL_LIBS})
|
|
|
|
target_compile_definitions(${target-name}
|
|
|
|
PUBLIC SOL_PRINT_ERRORS=1)
|
|
|
|
target_compile_options(${target-name}
|
|
|
|
PRIVATE
|
|
|
|
${--template-debugging-mode}
|
|
|
|
${--big-obj}
|
|
|
|
${--disable-permissive}
|
|
|
|
${--pedantic}
|
|
|
|
${--warn-all}
|
|
|
|
${--warn-pedantic}
|
|
|
|
${--warn-extra}
|
|
|
|
${--warn-errors}
|
|
|
|
${--utf8-literal-encoding}
|
|
|
|
${--utf8-source-encoding}
|
|
|
|
|
|
|
|
${--allow-unknown-warning}
|
|
|
|
${--allow-unknown-warning-option}
|
|
|
|
${--allow-noexcept-type}
|
2021-05-07 13:56:32 +08:00
|
|
|
${--allow-microsoft-cast}
|
2021-05-07 21:14:05 +08:00
|
|
|
${--allow-unreachable-code}
|
|
|
|
${--allow-padding-from-alignment}
|
2021-05-07 06:44:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_definitions(${target-name}
|
|
|
|
PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE)
|
|
|
|
|
|
|
|
if (SOL2_CI)
|
|
|
|
target_compile_definitions(${target-name}
|
|
|
|
PRIVATE SOL2_CI)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (SOL2_TESTS_EXAMPLES)
|
|
|
|
add_test(NAME ${target-name} COMMAND ${target-name})
|
|
|
|
endif()
|
|
|
|
if(SOL2_ENABLE_INSTALL)
|
|
|
|
install(TARGETS ${target-name} RUNTIME DESTINATION bin)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2021-03-06 23:48:25 +08:00
|
|
|
if (SOL2_DYNAMIC_LOADING_EXAMPLES OR SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE)
|
2018-02-12 16:55:14 +08:00
|
|
|
# # require_from_dll example
|
|
|
|
# just add the subdirectory
|
|
|
|
add_subdirectory(require_dll_example)
|
2018-12-20 12:17:15 +08:00
|
|
|
endif()
|
2018-02-13 06:01:30 +08:00
|
|
|
|
2021-03-06 23:48:25 +08:00
|
|
|
if (SOL2_INTEROP_EXAMPLES OR SOL2_INTEROP_EXAMPLES_SINGLE)
|
2018-02-11 13:53:53 +08:00
|
|
|
# # interop examples
|
|
|
|
add_subdirectory(interop/kaguya)
|
|
|
|
add_subdirectory(interop/tolua)
|
|
|
|
add_subdirectory(interop/LuaBridge)
|
|
|
|
add_subdirectory(interop/luwra)
|
2018-12-20 12:17:15 +08:00
|
|
|
endif()
|
2018-02-09 12:19:45 +08:00
|
|
|
|
2019-09-01 14:27:58 +08:00
|
|
|
# # In-depth customization example
|
|
|
|
add_subdirectory(customization)
|
|
|
|
|
2018-02-09 12:19:45 +08:00
|
|
|
# # single-source compilable examples
|
|
|
|
|
2021-03-06 14:03:23 +08:00
|
|
|
file(GLOB sol2.examples.sources source/*.cpp source/tutorials/*.cpp source/tutorials/quick_n_dirty/*.cpp source/docs/*.cpp)
|
2017-12-20 17:58:32 +08:00
|
|
|
|
2021-03-06 14:03:23 +08:00
|
|
|
function (MAKE_EXAMPLE example_source_file example_prefix target_sol)
|
2017-12-20 17:58:32 +08:00
|
|
|
get_filename_component(example_name ${example_source_file} NAME_WE)
|
|
|
|
file(RELATIVE_PATH example_source_file_relative ${CMAKE_SOURCE_DIR} ${example_source_file})
|
|
|
|
get_filename_component(example_output_relative_dir ${example_source_file_relative} DIRECTORY)
|
2017-12-25 01:32:23 +08:00
|
|
|
file(TO_CMAKE_PATH "${example_output_relative_dir}" example_output_relative_dir_name)
|
|
|
|
STRING(REGEX REPLACE "/" "." example_output_relative_dir_name "${example_output_relative_dir}")
|
|
|
|
if (example_output_relative_dir_name STREQUAL "")
|
2021-03-06 14:03:23 +08:00
|
|
|
set(example_output_name ${example_name})
|
|
|
|
set(example_name "${example_prefix}.${example_name}")
|
2017-12-25 01:32:23 +08:00
|
|
|
else()
|
2021-03-06 14:03:23 +08:00
|
|
|
set(example_output_name ${example_output_relative_dir_name}.${example_name})
|
|
|
|
set(example_name "${example_prefix}.${example_output_relative_dir_name}.${example_name}")
|
2017-12-25 01:32:23 +08:00
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2018-12-27 15:17:25 +08:00
|
|
|
add_executable(${example_name} ${example_source_file})
|
2021-05-07 06:44:25 +08:00
|
|
|
sol2_add_example_properties(${example_name})
|
2021-03-06 14:03:23 +08:00
|
|
|
target_link_libraries(${example_name}
|
2021-05-07 06:44:25 +08:00
|
|
|
PRIVATE ${target_sol})
|
2017-12-24 09:34:34 +08:00
|
|
|
endfunction(MAKE_EXAMPLE)
|
|
|
|
|
2018-12-20 12:17:15 +08:00
|
|
|
if (SOL2_EXAMPLES)
|
2021-03-06 14:03:23 +08:00
|
|
|
foreach(example_source_file ${sol2.examples.sources})
|
|
|
|
MAKE_EXAMPLE(${example_source_file} "sol2" sol2::sol2)
|
2017-12-26 12:27:22 +08:00
|
|
|
endforeach()
|
2018-12-20 12:17:15 +08:00
|
|
|
endif()
|
2018-02-11 13:53:53 +08:00
|
|
|
|
2018-12-20 14:18:07 +08:00
|
|
|
if (SOL2_EXAMPLES_SINGLE)
|
2021-03-06 14:03:23 +08:00
|
|
|
foreach(example_source_file ${sol2.examples.sources})
|
|
|
|
MAKE_EXAMPLE(${example_source_file} "sol2.single" sol2::sol2::single)
|
2018-12-20 12:17:15 +08:00
|
|
|
endforeach()
|
|
|
|
endif()
|