2017-12-20 17:58:32 +08:00
|
|
|
# # # # sol2
|
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013-2017 Rapptz, ThePhD, and contributors
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
# # # # sol2 tests
|
|
|
|
|
|
|
|
file(GLOB EXAMPLES_SRC *.cpp tutorials/quick_n_dirty/*.cpp)
|
|
|
|
source_group(examples FILES ${EXAMPLES_SRC})
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
function (MAKE_EXAMPLE example_source_file is_single)
|
|
|
|
if (is_single)
|
|
|
|
set(header_files ${SOL2_SINGLE_HEADER_SOURCES})
|
|
|
|
else()
|
|
|
|
set(header_files ${SOL2_HEADER_SOURCES})
|
|
|
|
endif()
|
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}")
|
2017-12-24 09:34:34 +08:00
|
|
|
if (is_single)
|
|
|
|
set(example_name "${example_name}.single")
|
|
|
|
endif()
|
2017-12-25 01:32:23 +08:00
|
|
|
if (example_output_relative_dir_name STREQUAL "")
|
|
|
|
set(example_output_name "${example_name}")
|
|
|
|
else()
|
|
|
|
set(example_output_name "${example_output_relative_dir_name}.${example_name}")
|
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
|
|
|
|
add_executable(${example_name} ${example_source_file} ${header_files})
|
2017-12-20 17:58:32 +08:00
|
|
|
set_target_properties(${example_name}
|
|
|
|
PROPERTIES
|
2017-12-25 01:32:23 +08:00
|
|
|
OUTPUT_NAME "${example_output_name}")
|
2017-12-24 09:34:34 +08:00
|
|
|
if (is_single)
|
|
|
|
target_include_directories(${example_name}
|
2017-12-25 01:32:23 +08:00
|
|
|
PRIVATE "${CMAKE_BINARY_DIR}/include/single/sol" "${LUA_INCLUDE_DIR}")
|
2017-12-24 09:34:34 +08:00
|
|
|
add_dependencies(${example_name} sol2_single_header)
|
|
|
|
else()
|
|
|
|
target_include_directories(${example_name}
|
|
|
|
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}")
|
|
|
|
endif()
|
2017-12-27 20:42:37 +08:00
|
|
|
target_compile_features(${example_name}
|
|
|
|
PRIVATE ${CXX_FEATURES})
|
2017-12-24 09:34:34 +08:00
|
|
|
target_link_libraries(${example_name} ${LUA_LIBRARIES})
|
|
|
|
if(CMAKE_DL_LIBS)
|
|
|
|
target_link_libraries(${example_name} ${CMAKE_DL_LIBS})
|
|
|
|
endif()
|
2017-12-26 00:44:04 +08:00
|
|
|
if (CI)
|
|
|
|
target_compile_definitions(${example_name}
|
|
|
|
PRIVATE SOL2_CI)
|
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
if (MSVC)
|
2017-12-26 00:44:04 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
else()
|
2017-12-26 00:44:04 +08:00
|
|
|
target_compile_options(${example_name}
|
|
|
|
PRIVATE -Wno-noexcept-type)
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
2017-12-26 00:44:04 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
if (TESTS_EXAMPLES)
|
|
|
|
if ((NOT is_single) OR (is_single AND TESTS_SINGLE))
|
2017-12-25 01:32:23 +08:00
|
|
|
add_test(NAME ${example_output_name} COMMAND ${example_name})
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-12-25 01:32:23 +08:00
|
|
|
install(TARGETS ${example_name} RUNTIME DESTINATION bin)
|
2017-12-24 09:34:34 +08:00
|
|
|
endfunction(MAKE_EXAMPLE)
|
|
|
|
|
|
|
|
foreach(example_source_file ${EXAMPLES_SRC})
|
|
|
|
MAKE_EXAMPLE(${example_source_file} FALSE)
|
2017-12-20 17:58:32 +08:00
|
|
|
endforeach()
|
2017-12-26 12:27:22 +08:00
|
|
|
|
|
|
|
if (EXAMPLES_SINGLE AND SOL2_SINGLE_FOUND)
|
|
|
|
foreach(example_source_file ${EXAMPLES_SRC})
|
|
|
|
MAKE_EXAMPLE(${example_source_file} TRUE)
|
|
|
|
endforeach()
|
|
|
|
endif()
|