chore: update build script
- change project layout for better understanding. - update build script for more close to standard cmake way.
This commit is contained in:
52
CMake/FindSTB.cmake
Normal file
52
CMake/FindSTB.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
# - Find STB library
|
||||
# Find the STB headers
|
||||
#
|
||||
# This module defines the following variables:
|
||||
# STB_FOUND - True if STB was found
|
||||
# STB_INCLUDE_DIRS - Location of the STB headers
|
||||
#
|
||||
# This module defines the following imported targets:
|
||||
# STB::STB - Header-only interface library for STB
|
||||
|
||||
# STB_ROOT must be specified by the user
|
||||
if (NOT DEFINED STB_ROOT)
|
||||
set(STB_FOUND FALSE)
|
||||
else ()
|
||||
# Look for STB_image.h in the specified STB_ROOT directory
|
||||
find_path(STB_INCLUDE_DIR
|
||||
NAMES STB_image.h
|
||||
HINTS ${STB_ROOT}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# Check find status
|
||||
if(STB_INCLUDE_DIR)
|
||||
set(STB_FOUND TRUE)
|
||||
set(STB_INCLUDE_DIRS ${STB_INCLUDE_DIR})
|
||||
else()
|
||||
set(STB_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
# Hide intermediate variables
|
||||
mark_as_advanced(STB_INCLUDE_DIR)
|
||||
endif ()
|
||||
|
||||
# Check find result
|
||||
if (STB_FOUND)
|
||||
# Add library
|
||||
message(STATUS "Found STB library")
|
||||
# Add library
|
||||
add_library(STB INTERFACE IMPORTED)
|
||||
# Add alias to it
|
||||
add_library(STB::STB ALIAS STB)
|
||||
# Setup header files
|
||||
set_target_properties(STB PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${STB_INCLUDE_DIRS}"
|
||||
)
|
||||
else ()
|
||||
# If it is required, show infomations.
|
||||
if (std_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Fail to find STB library.")
|
||||
endif ()
|
||||
endif ()
|
||||
@@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define LIBCMO_VER_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define LIBCMO_VER_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define LIBCMO_VER_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define LIBCMO_VER_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
|
||||
@@ -1,9 +0,0 @@
|
||||
if (WIN32)
|
||||
# In Windows, we should not import Iconv.
|
||||
# Send a notice to programmer.
|
||||
message("Windows environment detected, skip finding Iconv!")
|
||||
else ()
|
||||
# In non-Windows, we simply import Iconv from CMake preset.
|
||||
# It will produce Iconv::Iconv target for including and linking.
|
||||
find_package(Iconv REQUIRED)
|
||||
endif ()
|
||||
@@ -1,14 +0,0 @@
|
||||
# Check stb path variable
|
||||
if (NOT DEFINED STB_IMAGE_PATH)
|
||||
message(FATAL_ERROR "You must set STB_IMAGE_PATH variable to the root directory of std-image repository.")
|
||||
endif()
|
||||
|
||||
# Add library
|
||||
add_library(stb-image INTERFACE IMPORTED)
|
||||
# Add alias for it
|
||||
add_library(stb::stb-image ALIAS stb-image)
|
||||
# Setup header files
|
||||
set_target_properties(stb-image PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${STB_IMAGE_PATH}"
|
||||
)
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
# Check YYCC path environment variable
|
||||
if (NOT DEFINED YYCC_PATH)
|
||||
message(FATAL_ERROR "You must set YYCC_PATH variable to one of YYCC CMake distribution installation path.")
|
||||
endif()
|
||||
|
||||
# Find YYCC library
|
||||
# It will produce YYCC::YYCCommonplace target for including and linking.
|
||||
#
|
||||
# Please note we MUST set CMake variable YYCCommonplace_ROOT to make sure CMake can found YYCC in out given path.
|
||||
# The cache status of YYCCommonplace_ROOT is doesn't matter.
|
||||
# CMake will throw error if we use HINTS feature in find_package to find YYCC.
|
||||
set(YYCCommonplace_ROOT ${YYCC_PATH} CACHE PATH
|
||||
"The path to YYCC CMake distribution installation path.")
|
||||
find_package(YYCCommonplace REQUIRED)
|
||||
@@ -1,34 +0,0 @@
|
||||
if (WIN32)
|
||||
# In Windows, we use custom way to import ZLib.
|
||||
# Before using this CMake file in Windows, you should do following steps first.
|
||||
# 1. Get ZLib repository: https://github.com/madler/zlib
|
||||
# 2. Navigate to `contrib/vstudio` and choose a proper Visual Studio project according to your environment.
|
||||
# 3. Open project file and build. Then you will get the built binary.
|
||||
# 4. The directory binary located is the argument you should passed to ZLIB_BINARY_PATH, for example: `contrib/vstudio/vc14/x64/ZlibDllRelease`
|
||||
|
||||
# Check ZLib path variable
|
||||
if (NOT DEFINED ZLIB_HEADER_PATH)
|
||||
message(FATAL_ERROR "You must set ZLIB_HEADER_PATH to the root directory of ZLib repository.")
|
||||
endif()
|
||||
if (NOT DEFINED ZLIB_BINARY_PATH)
|
||||
message(FATAL_ERROR "You must set ZLIB_BINARY_PATH to the directory where include binary built by contributed Visual Studio project.")
|
||||
endif()
|
||||
# Add imported library
|
||||
add_library(ZLIB INTERFACE IMPORTED)
|
||||
# Add alias for it to let it has the same behavior with CMake imported ZLib.
|
||||
add_library(ZLIB::ZLIB ALIAS ZLIB)
|
||||
# Setup header files
|
||||
set_target_properties(ZLIB PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${ZLIB_HEADER_PATH}"
|
||||
)
|
||||
# Setup lib files
|
||||
set_target_properties(ZLIB PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
"${ZLIB_BINARY_PATH}/zlibwapi.lib"
|
||||
)
|
||||
else ()
|
||||
# In non-Windows, we simply import ZLib from CMake preset.
|
||||
# It will produce ZLIB::ZLIB target for including and linking.
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif ()
|
||||
Reference in New Issue
Block a user