2018-12-20 12:17:15 +08:00
# # # # sol3
# The MIT License (MIT)
#
2019-03-13 17:18:06 +08:00
# Copyright (c) 2013-2019 Rapptz, ThePhD, and contributors
2018-12-20 12:17:15 +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.
# # # # sol3, single
# # # Required minimum version statement
cmake_minimum_required ( VERSION 3.5.0 )
# single header files
file ( GLOB SOL2_SINGLE_HEADER_SOURCES ${ CMAKE_CURRENT_SOURCE_DIR } /include/**/*.hpp )
source_group ( sol2_single FILES ${ SOL2_SINGLE_HEADER_SOURCES } )
2019-05-22 07:17:31 +08:00
# # # sol3 Library, single
# # Add a target for sol3's library to be included by external users
2018-12-20 12:17:15 +08:00
# # single version
add_library ( sol2_single INTERFACE )
add_library ( sol2::sol2_single ALIAS sol2_single )
target_sources ( sol2_single INTERFACE ${ SOL2_SINGLE_HEADER_SOURCES } )
set_target_properties ( sol2_single
P R O P E R T I E S
E X P O R T _ N A M E s o l 2 : : s o l 2 _ s i n g l e )
target_include_directories ( sol2_single INTERFACE
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e >
$ < I N S T A L L _ I N T E R F A C E : s o l / s i n g l e / i n c l u d e > )
2019-05-22 07:17:31 +08:00
# # # sol3 single generation header
2018-12-20 12:17:15 +08:00
# generate the single header if we can find the python3 interpreter
if ( SOL2_GENERATE_SINGLE )
find_package ( PythonInterp 3 )
if ( NOT PYTHONINTERP_FOUND )
message ( FATAL_ERROR "sol2 single header cannot be generated as python 3 has not been found: install or set the python 3 interpreter to generate the single header" )
endif ( )
# to generate, need all of the existing header files
file ( GLOB sol2_generated_header_sources ${ CMAKE_CURRENT_SOURCE_DIR } /../include/**/*.* )
add_custom_command (
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l "
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s i n g l e . p y " - - i n p u t " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / i n c l u d e " - - o u t p u t " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l / s o l . h p p "
D E P E N D S " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s i n g l e . p y " " $ { s o l 2 _ g e n e r a t e d _ h e a d e r _ s o u r c e s } "
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l / s o l . h p p " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l / f o r w a r d . h p p " )
add_custom_target ( sol2_single_header_generator ALL
D E P E N D S " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s i n g l e . p y "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l / s o l . h p p " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / s o l / f o r w a r d . h p p "
" $ { s o l 2 _ g e n e r a t e d _ h e a d e r _ s o u r c e s } " )
2019-05-22 07:17:31 +08:00
# # # sol3 generated single header library
2018-12-20 12:17:15 +08:00
add_library ( sol2_single_generated INTERFACE )
add_library ( sol2::sol2_single_generated ALIAS sol2_single_generated )
set_target_properties ( sol2_single_generated
P R O P E R T I E S
E X P O R T _ N A M E s o l 2 : : s o l 2 _ s i n g l e _ g e n e r a t e d
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e " )
add_dependencies ( sol2_single_generated sol2_single_header_generator )
2020-11-02 00:10:36 +08:00
if ( SOL2_ENABLE_INSTALL )
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/include/sol/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/sol/forward.hpp"
D E S T I N A T I O N i n c l u d e / s o l / s i n g l e / s o l )
endif ( )
2018-12-20 12:17:15 +08:00
endif ( )