Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Jun 13, 2018
1 parent 6c55aaf commit 1f461db
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Michele Caini aka skypjack
Paolo Monteverde aka morbo84
David Nerjes aka DavidHamburg
Indi Kernick aka Kerndog73
Malte Müller-Rowold aka m-waka
68 changes: 37 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

cmake_minimum_required(VERSION 3.2)

include(GNUInstallDirs)

#
# Building in-tree is not allowed (we take care of your craziness).
#
Expand All @@ -20,6 +18,8 @@ endif()

project(entt VERSION 2.6.1)

include(GNUInstallDirs)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
Expand All @@ -44,18 +44,18 @@ option(USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if availbale." ON)
if(NOT MSVC AND USE_LIBCPP)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)

cmake_push_check_state()

set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -stdlib=libc++")

check_cxx_source_compiles("
#include<type_traits>
int main() { return std::is_same<int, int>::value ? 0 : 1; }
" HAS_LIBCPP)

if(USE_LIBCPP AND NOT HAS_LIBCPP)
message(WARNING "The option USE_LIBCPP is set (by default) but libc++ is not available. The flag will not be added to the target")
if(NOT HAS_LIBCPP)
message(WARNING "The option USE_LIBCPP is set (by default) but libc++ is not available. The flag will not be added to the target.")
endif()

cmake_pop_check_state()
Expand All @@ -67,33 +67,34 @@ endif()

add_library(EnTT INTERFACE)

target_include_directories(EnTT INTERFACE
target_include_directories(
EnTT INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_definitions(EnTT
target_compile_definitions(
EnTT
INTERFACE $<$<AND:$<CONFIG:Debug>,$<NOT:$<CXX_COMPILER_ID:MSVC>>>:DEBUG>
INTERFACE $<$<AND:$<CONFIG:Release>,$<NOT:$<CXX_COMPILER_ID:MSVC>>>:RELEASE>
)

if(ENTT_COMPILE_OPTIONS)
target_compile_options(EnTT
target_compile_options(
EnTT
INTERFACE $<$<AND:$<CONFIG:Debug>,$<NOT:$<CXX_COMPILER_ID:MSVC>>>:-O0 -g>
# it seems that -O3 ruins the performance when using clang ...
INTERFACE $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>>:-O2>
# ... on the other side, GCC is incredibly comfortable with it.
INTERFACE $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU>>:-O3>
)
endif()

if(USE_LIBCPP AND HAS_LIBCPP)
target_compile_options(EnTT BEFORE
INTERFACE -stdlib=libc++
)
target_compile_options(EnTT BEFORE INTERFACE -stdlib=libc++)
endif()

target_compile_features(EnTT
INTERFACE cxx_std_14
)
target_compile_features(EnTT INTERFACE cxx_std_14)

#
# Install EnTT
Expand All @@ -105,42 +106,47 @@ else()
set(ENTT_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/entt)
endif()

install(DIRECTORY src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS EnTT EXPORT EnTTTargets)

export(EXPORT EnTTTargets
FILE ${CMAKE_CURRENT_BINARY_DIR}/EnTTTargets.cmake
)
export(EXPORT EnTTTargets FILE ${entt_BINARY_DIR}/EnTTTargets.cmake)

install(EXPORT EnTTTargets
install(
EXPORT EnTTTargets
FILE EnTTTargets.cmake
DESTINATION ${ENTT_INSTALL_CONFIGDIR}
DESTINATION ${ENTT_INSTALL_CONFIGDIR}
)

# build tree package config file
#
# Build tree package config file
#

configure_file(cmake/in/EnTTBuildConfig.cmake.in EnTTConfig.cmake @ONLY)

include(CMakePackageConfigHelpers)

# install tree package config file
configure_package_config_file(cmake/in/EnTTConfig.cmake.in
#
# Install tree package config file
#

configure_package_config_file(
cmake/in/EnTTConfig.cmake.in
${ENTT_INSTALL_CONFIGDIR}/EnTTConfig.cmake
INSTALL_DESTINATION ${ENTT_INSTALL_CONFIGDIR}
INSTALL_DESTINATION ${ENTT_INSTALL_CONFIGDIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/EnTTConfigVersion.cmake
${entt_BINARY_DIR}/EnTTConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ENTT_INSTALL_CONFIGDIR}/EnTTConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/EnTTConfigVersion.cmake
install(
FILES
${entt_BINARY_DIR}/${ENTT_INSTALL_CONFIGDIR}/EnTTConfig.cmake
${entt_BINARY_DIR}/EnTTConfigVersion.cmake
DESTINATION ${ENTT_INSTALL_CONFIGDIR}
)

Expand Down
8 changes: 4 additions & 4 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#

set(DOXY_SOURCE_DIRECTORY ${entt_SOURCE_DIR}/src)
set(DOXY_DOCS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(DOXY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(DOXY_DOCS_DIRECTORY ${entt_SOURCE_DIR}/docs)
set(DOXY_OUTPUT_DIRECTORY ${entt_BINARY_DIR})

configure_file(doxy.in doxy.cfg @ONLY)
configure_file(doxy.in ${entt_BINARY_DIR}/doxy.cfg @ONLY)

add_custom_target(
docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy.cfg
COMMAND ${DOXYGEN_EXECUTABLE} ${entt_BINARY_DIR}/doxy.cfg
WORKING_DIRECTORY ${entt_SOURCE_DIR}
VERBATIM
SOURCES doxy.in
Expand Down

0 comments on commit 1f461db

Please sign in to comment.