Fixed and updated CMake configuration

This commit is contained in:
Chlumsky 2022-01-14 13:30:41 +01:00
parent b086f93a36
commit 50d1a1c275
4 changed files with 42 additions and 42 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ bin/*.lib
output.png
out/
build/
/cmake-gen.bat

View File

@ -1,29 +1,32 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.15)
project(msdf-atlas-gen VERSION 1.2 LANGUAGES CXX)
option(MSDF_ATLAS_GEN_BUILD_STANDALONE "Build the msdf-atlas-gen standalone executable" ON)
set(MSDFGEN_BUILD_MSDFGEN_STANDALONE OFF CACHE BOOL "Build the msdfgen standalone executable")
option(MSDF_ATLAS_GEN_MSDFGEN_EXTERNAL "Do not build the msdfgen submodule but find it as an external package" OFF)
if(NOT MSDF_ATLAS_GEN_MSDFGEN_EXTERNAL)
set(MSDFGEN_BUILD_STANDALONE OFF CACHE BOOL "Build the msdfgen standalone executable")
set(MSDFGEN_USE_OPENMP OFF CACHE INTERNAL "Build with OpenMP support for multithreaded code (disabled for atlas gen)" FORCE)
set(MSDFGEN_USE_CPP11 ON CACHE INTERNAL "Build with C++11 enabled (always enabled for atlas gen)" FORCE)
set(MSDFGEN_INSTALL OFF CACHE BOOL "Generate installation target for msdfgen")
add_subdirectory(msdfgen)
endif()
project(msdf-atlas-gen VERSION 1.2 LANGUAGES CXX)
find_package(Threads REQUIRED)
file(GLOB_RECURSE msdf-atlas-gen_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"msdf-atlas-gen/*.h"
"msdf-atlas-gen/*.hpp"
)
if(MSDF_ATLAS_GEN_MSDFGEN_EXTERNAL)
find_package(msdfgen REQUIRED)
else()
add_subdirectory(msdfgen)
endif()
file(GLOB_RECURSE msdf-atlas-gen_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"msdf-atlas-gen/*.cpp"
)
file(GLOB_RECURSE MSDF_ATLAS_GEN_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "msdf-atlas-gen/*.h" "msdf-atlas-gen/*.hpp")
file(GLOB_RECURSE MSDF_ATLAS_GEN_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "msdf-atlas-gen/*.cpp")
# msdf-atlas-gen library
add_library(msdf-atlas-gen ${msdf-atlas-gen_SOURCES} ${msdf-atlas-gen_HEADERS})
add_library(msdf-atlas-gen ${MSDF_ATLAS_GEN_HEADERS} ${MSDF_ATLAS_GEN_SOURCES})
add_library(msdf-atlas-gen::msdf-atlas-gen ALIAS msdf-atlas-gen)
set_target_properties(msdf-atlas-gen PROPERTIES PUBLIC_HEADER "${msdf-atlas-gen_HEADERS}")
set_target_properties(msdf-atlas-gen PROPERTIES PUBLIC_HEADER "${MSDF_ATLAS_GEN_HEADERS}")
target_include_directories(msdf-atlas-gen
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
@ -32,29 +35,25 @@ PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/artery-font-format
)
if (MSVC)
target_compile_definitions(msdf-atlas-gen PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()
target_compile_features(msdf-atlas-gen PUBLIC cxx_std_11)
target_link_libraries(msdf-atlas-gen PUBLIC Threads::Threads msdfgen::msdfgen msdfgen::msdfgen-ext)
# TODO make these public in msdfgen so that this doesn't have to be repeated here
if(FREETYPE_WITH_PNG)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
target_link_libraries(msdf-atlas-gen PUBLIC ZLIB::ZLIB PNG::PNG)
endif()
if(FREETYPE_WITH_HARFBUZZ)
# No FindHarfBuzz.cmake available so falling back to CMAKE_LIBRARY_PATH
find_library(FREETYPE_HARFBUZZ_LIB "harfbuzz")
target_link_libraries(msdf-atlas-gen PUBLIC "${FREETYPE_HARFBUZZ_LIB}")
endif()
target_link_libraries(msdf-atlas-gen PUBLIC Threads::Threads msdfgen::msdfgen)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT msdf-atlas-gen)
# msdf-atlas-gen standalone executable
if(MSDF_ATLAS_GEN_BUILD_STANDALONE)
add_executable(msdf-atlas-gen-standalone msdf-atlas-gen/main.cpp)
set_target_properties(msdf-atlas-gen-standalone PROPERTIES ARCHIVE_OUTPUT_DIRECTORY archive OUTPUT_NAME msdf-atlas-gen)
target_compile_definitions(msdf-atlas-gen-standalone PUBLIC MSDF_ATLAS_STANDALONE)
target_compile_features(msdf-atlas-gen-standalone PUBLIC cxx_std_11)
target_link_libraries(msdf-atlas-gen-standalone PUBLIC msdf-atlas-gen::msdf-atlas-gen)
set(MSDF_ATLAS_GEN_STANDALONE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/msdf-atlas-gen/main.cpp")
if(MSVC)
set(MSDF_ATLAS_GEN_STANDALONE_SOURCES ${MSDF_ATLAS_GEN_STANDALONE_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/msdf-atlas-gen.rc")
endif()
add_executable(msdf-atlas-gen-standalone ${MSDF_ATLAS_GEN_STANDALONE_SOURCES})
target_compile_definitions(msdf-atlas-gen-standalone PUBLIC MSDF_ATLAS_STANDALONE)
set_target_properties(msdf-atlas-gen-standalone PROPERTIES
OUTPUT_NAME msdf-atlas-gen
ARCHIVE_OUTPUT_NAME msdf-atlas-gen-standalone
# Avoid deleting msdf-atlas-gen.lib during clean
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
target_link_libraries(msdf-atlas-gen-standalone PUBLIC msdf-atlas-gen::msdf-atlas-gen)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT msdf-atlas-gen-standalone)
endif()

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Msdfgen", "msdfgen\Msdfgen.vcxproj", "{84BE2D91-F071-4151-BE12-61460464C494}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msdfgen", "msdfgen\msdfgen.vcxproj", "{84BE2D91-F071-4151-BE12-61460464C494}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msdf-atlas-gen", "msdf-atlas-gen.vcxproj", "{223EDB94-5B35-45F2-A584-273DE6E45F6F}"
ProjectSection(ProjectDependencies) = postProject

@ -1 +1 @@
Subproject commit 64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0
Subproject commit 4e8ff2321ea9696801675c908a4822c4d8e71eb8