diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9f4da5dab8..1ac80e0d91 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,7 @@ Specify library name and version: **lib/1.0** -- [ ] I've read the [guidelines](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.mdt) for contributing. +- [ ] I've read the [guidelines](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md) for contributing. - [ ] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes. - [ ] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version. - [ ] I've tried at least one configuration locally with the [conan-center hook](https://github.com/conan-io/hooks.git) activated. - diff --git a/docs/error_knowledge_base.md b/docs/error_knowledge_base.md index 59724ec393..3d56c753c8 100644 --- a/docs/error_knowledge_base.md +++ b/docs/error_knowledge_base.md @@ -294,4 +294,8 @@ The CMake definition CMAKE_VERBOSE_MAKEFILE helps for debugging when developing, #### **#KB-H047: "NO ASCII CHARACTERS"** -According to PEP [263](https://www.python.org/dev/peps/pep-0263/), Unicode literals should only appear in Python code if the encoding is declared on one of the first two lines of the source file. Without such a declaration, any Unicode literal will cause a syntax error for Python 2 interpreters. \ No newline at end of file +According to PEP [263](https://www.python.org/dev/peps/pep-0263/), Unicode literals should only appear in Python code if the encoding is declared on one of the first two lines of the source file. Without such a declaration, any Unicode literal will cause a syntax error for Python 2 interpreters. + +#### **#KB-H048: "CMAKE VERSION REQUIRED"** + +The file test_package/CMakeLists.txt should require CMake 3.1 by default: `cmake_minimum_required(VERSION 3.1)`. The CMake wrapper file can require CMake 2.8, because Conan recipe and the test package are totally separated. However, if `CMAKE_CXX_STANDARD` or `CXX_STANDARD` is explicit, CMake 3.1 is mandatory. diff --git a/docs/supported_platforms_and_configurations.md b/docs/supported_platforms_and_configurations.md index e7c817c935..aefd777551 100644 --- a/docs/supported_platforms_and_configurations.md +++ b/docs/supported_platforms_and_configurations.md @@ -12,7 +12,9 @@ - Architectures: x86_64 - Build types: Release, Debug - Runtimes: MT/MD (Release), MTd/MDd (Debug) -- Shared/Static (option `"shared": [True, False]` in the recipe when available) +- Options: + - Shared, Static (option `"shared": [True, False]` in the recipe when available) + - Header Only (option `"header_only": [True, False]` is only added with the value True) ## Linux @@ -24,7 +26,9 @@ - Clang compiler: `libstdc++`, `libc++` - Architectures: x86_64 - Build types: Release, Debug -- Options: Shared, Static (option `"shared": [True, False]` in the recipe when available) +- Options: + - Shared, Static (option `"shared": [True, False]` in the recipe when available) + - Header Only (option `"header_only": [True, False]` is only added with the value True) ## OSX @@ -32,4 +36,6 @@ - C++ Standard Library (`libcxx`): `libc++` - Architectures: x86_64 - Build types: Release, Debug -- Options: Shared, Static (option ``"shared": [True, False]`` in the recipe when available) +- Options: + - Shared, Static (option ``"shared": [True, False]`` in the recipe when available) + - Header Only (option `"header_only": [True, False]` is only added with the value True) diff --git a/recipes/easy_profiler/all/CMakeLists.txt b/recipes/easy_profiler/all/CMakeLists.txt new file mode 100644 index 0000000000..c986d294c7 --- /dev/null +++ b/recipes/easy_profiler/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/easy_profiler/all/conandata.yml b/recipes/easy_profiler/all/conandata.yml new file mode 100644 index 0000000000..753771f92e --- /dev/null +++ b/recipes/easy_profiler/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.1.0": + url: "https://github.com/yse/easy_profiler/archive/v2.1.0.tar.gz" + sha256: "fabf95d59ede9da4873aebd52ef8a762fa8578dcdbcc6d7cdd811b5a7c3367ad" diff --git a/recipes/easy_profiler/all/conanfile.py b/recipes/easy_profiler/all/conanfile.py new file mode 100644 index 0000000000..90a431c61a --- /dev/null +++ b/recipes/easy_profiler/all/conanfile.py @@ -0,0 +1,86 @@ +from conans import ConanFile, tools, CMake +import os +import glob + + +class EasyProfilerConan(ConanFile): + name = "easy_profiler" + description = "Lightweight profiler library for c++" + license = "MIT" + topics = ("conan", "easy_profiler") + homepage = "https://github.com/yse/easy_profiler/" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/*"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + short_paths = True + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + url = self.conan_data["sources"][self.version]["url"] + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + # Don't build the GUI because it is dependent on Qt + self._cmake.definitions["EASY_PROFILER_NO_GUI"] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE.MIT", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE.APACHE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + os.remove(os.path.join(self.package_folder, "LICENSE.MIT")) + os.remove(os.path.join(self.package_folder, "LICENSE.APACHE")) + if self.settings.os == "Windows": + for dll_file in \ + glob.glob(os.path.join(self.package_folder, "bin", "*.dll")): + if os.path.basename(dll_file).startswith(("concrt", "msvcp", + "vcruntime")): + os.remove(dll_file) + + def package_info(self): + self.cpp_info.libs = ["easy_profiler"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m", "pthread"] + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["psapi", "ws2_32"] + if not self.options.shared: + self.cpp_info.defines.append("EASY_PROFILER_STATIC") diff --git a/recipes/easy_profiler/all/test_package/CMakeLists.txt b/recipes/easy_profiler/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..0b46954340 --- /dev/null +++ b/recipes/easy_profiler/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/easy_profiler/all/test_package/conanfile.py b/recipes/easy_profiler/all/test_package/conanfile.py new file mode 100644 index 0000000000..5934fccac4 --- /dev/null +++ b/recipes/easy_profiler/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + self.run( os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/easy_profiler/all/test_package/example.cpp b/recipes/easy_profiler/all/test_package/example.cpp new file mode 100644 index 0000000000..fc452d1c9f --- /dev/null +++ b/recipes/easy_profiler/all/test_package/example.cpp @@ -0,0 +1,53 @@ +//#define FULL_DISABLE_PROFILER +#include +#include +#include +#include +#include +#include +#include + +#define BUILD_WITH_EASY_PROFILER +#include +#include +#include + +int RENDER_STEPS = 300; + +//#define SAMPLE_NETWORK_TEST + +void localSleep(uint64_t magic=200000) +{ + //PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Blue); + volatile int i = 0; + for (; i < magic; ++i); +} + +void renderThread(){ + EASY_THREAD("Render"); + uint64_t n = 20; + + for (int i = 0; i < RENDER_STEPS; i++) + { + localSleep(1200000); + n += 20; + if (n >= 700) + n = 20; + //std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } +} + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char* argv[]) +{ + #ifndef SAMPLE_NETWORK_TEST + EASY_PROFILER_ENABLE; + #endif + EASY_MAIN_THREAD; + profiler::startListen(); + + renderThread(); + + return 0; +} diff --git a/recipes/easy_profiler/config.yml b/recipes/easy_profiler/config.yml new file mode 100644 index 0000000000..dfff490f9a --- /dev/null +++ b/recipes/easy_profiler/config.yml @@ -0,0 +1,3 @@ +versions: + "2.1.0": + folder: all diff --git a/recipes/shaderc/all/CMakeLists.txt b/recipes/shaderc/all/CMakeLists.txt new file mode 100644 index 0000000000..4d393c7a86 --- /dev/null +++ b/recipes/shaderc/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/shaderc/all/conandata.yml b/recipes/shaderc/all/conandata.yml new file mode 100644 index 0000000000..e5f374c927 --- /dev/null +++ b/recipes/shaderc/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2019.0": + url: "https://github.com/google/shaderc/archive/v2019.0.tar.gz" + sha256: "1018cd02be52295272fdbffa056ee24b881be277c83d039ad554d91230f4e11b" +patches: + "2019.0": + - patch_file: "patches/2019.0/fix-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/2019.0/fix-spvc.patch" + base_path: "source_subfolder" diff --git a/recipes/shaderc/all/conanfile.py b/recipes/shaderc/all/conanfile.py new file mode 100644 index 0000000000..4f7fdbe981 --- /dev/null +++ b/recipes/shaderc/all/conanfile.py @@ -0,0 +1,105 @@ +import os + +from conans import ConanFile, CMake, tools + +class ShadercConan(ConanFile): + name = "shaderc" + description = "A collection of tools, libraries and tests for shader compilation." + license = "Apache-2.0" + topics = ("conan", "shaderc", "glsl", "hlsl", "msl", "spirv", "spir-v", "glslc", "spvc") + homepage = "https://github.com/google/shaderc" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "spvc": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "spvc": False + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def requirements(self): + self.requires("glslang/8.13.3559") + self.requires("spirv-tools/v2020.3") + if self.options.spvc: + self.requires("spirv-cross/20200629") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-" + self.version, self._source_subfolder) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + self._cmake.definitions["SHADERC_ENABLE_SPVC"] = self.options.spvc + self._cmake.definitions["SHADERC_SKIP_INSTALL"] = False + self._cmake.definitions["SHADERC_SKIP_TESTS"] = True + self._cmake.definitions["SHADERC_SPVC_ENABLE_DIRECT_LOGGING"] = False + self._cmake.definitions["SHADERC_SPVC_DISABLE_CONTEXT_LOGGING"] = False + self._cmake.definitions["SHADERC_ENABLE_WERROR_COMPILE"] = False + if self.settings.compiler == "Visual Studio": + self._cmake.definitions["SHADERC_ENABLE_SHARED_CRT"] = str(self.settings.compiler.runtime).startswith("MD") + self._cmake.definitions["ENABLE_CODE_COVERAGE"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "shaderc" if self.options.shared else "shaderc_static" + self.cpp_info.libs = self._get_ordered_libs() + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("pthread") + if not self.options.shared and tools.stdcpp_library(self): + self.cpp_info.system_libs.append(tools.stdcpp_library(self)) + if self.options.shared: + self.cpp_info.defines.append("SHADERC_SHAREDLIB") + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + def _get_ordered_libs(self): + libs = ["shaderc_shared" if self.options.shared else "shaderc"] + if not self.options.shared: + libs.append("shaderc_util") + if self.options.spvc: + libs.append("shaderc_spvc_shared" if self.options.shared else "shaderc_spvc") + return libs diff --git a/recipes/shaderc/all/patches/2019.0/fix-cmake.patch b/recipes/shaderc/all/patches/2019.0/fix-cmake.patch new file mode 100644 index 0000000000..1fee3bf35e --- /dev/null +++ b/recipes/shaderc/all/patches/2019.0/fix-cmake.patch @@ -0,0 +1,402 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,7 +70,6 @@ endif(MSVC) + + # Configure subdirectories. + # We depend on these for later projects, so they should come first. +-add_subdirectory(third_party) + + if(SHADERC_ENABLE_SPVC) + add_subdirectory(libshaderc_spvc) +@@ -79,12 +78,11 @@ endif() + add_subdirectory(libshaderc_util) + add_subdirectory(libshaderc) + add_subdirectory(glslc) +-add_subdirectory(examples) + + add_custom_target(build-version + ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/utils/update_build_version.py +- ${shaderc_SOURCE_DIR} ${spirv-tools_SOURCE_DIR} ${glslang_SOURCE_DIR} ++ ${shaderc_SOURCE_DIR} + COMMENT "Update build-version.inc in the Shaderc build directory (if necessary).") + + function(define_pkg_config_file NAME LIBS) +--- a/cmake/utils.cmake ++++ b/cmake/utils.cmake +@@ -11,7 +11,6 @@ function(shaderc_default_c_compile_options TARGET) + if (NOT "${MSVC}") + target_compile_options(${TARGET} PRIVATE -Wall -Werror -fvisibility=hidden) + if (NOT "${MINGW}") +- target_compile_options(${TARGET} PRIVATE -fPIC) + endif() + if (ENABLE_CODE_COVERAGE) + # The --coverage option is a synonym for -fprofile-arcs -ftest-coverage +@@ -24,10 +23,6 @@ function(shaderc_default_c_compile_options TARGET) + endif() + if (NOT SHADERC_ENABLE_SHARED_CRT) + if (WIN32) +- # For MinGW cross compile, statically link to the libgcc runtime. +- # But it still depends on MSVCRT.dll. +- set_target_properties(${TARGET} PROPERTIES +- LINK_FLAGS "-static -static-libgcc") + endif(WIN32) + endif(NOT SHADERC_ENABLE_SHARED_CRT) + else() +@@ -40,13 +35,8 @@ endfunction(shaderc_default_c_compile_options) + function(shaderc_default_compile_options TARGET) + shaderc_default_c_compile_options(${TARGET}) + if (NOT "${MSVC}") +- target_compile_options(${TARGET} PRIVATE -std=c++11) + if (NOT SHADERC_ENABLE_SHARED_CRT) + if (WIN32) +- # For MinGW cross compile, statically link to the C++ runtime. +- # But it still depends on MSVCRT.dll. +- set_target_properties(${TARGET} PROPERTIES +- LINK_FLAGS "-static -static-libgcc -static-libstdc++") + endif(WIN32) + endif(NOT SHADERC_ENABLE_SHARED_CRT) + endif() +--- a/glslc/CMakeLists.txt ++++ b/glslc/CMakeLists.txt +@@ -16,31 +16,19 @@ add_library(glslc STATIC + ) + + shaderc_default_compile_options(glslc) +-target_include_directories(glslc PUBLIC ${glslang_SOURCE_DIR}) +-target_link_libraries(glslc PRIVATE glslang OSDependent OGLCompiler +- HLSL glslang SPIRV ${CMAKE_THREAD_LIBS_INIT}) +-target_link_libraries(glslc PRIVATE shaderc_util shaderc) ++target_link_libraries(glslc PRIVATE ${CMAKE_THREAD_LIBS_INIT}) ++target_link_libraries(glslc PUBLIC shaderc_util shaderc) + + add_executable(glslc_exe src/main.cc) + shaderc_default_compile_options(glslc_exe) +-target_include_directories(glslc_exe PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/.. ${spirv-tools_SOURCE_DIR}/include) ++target_include_directories(glslc_exe PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) + set_target_properties(glslc_exe PROPERTIES OUTPUT_NAME glslc) +-target_link_libraries(glslc_exe PRIVATE glslc shaderc_util shaderc) ++target_link_libraries(glslc_exe PRIVATE glslc shaderc_util shaderc CONAN_PKG::spirv-tools) + add_dependencies(glslc_exe build-version) + +-shaderc_add_tests( +- TEST_PREFIX glslc +- LINK_LIBS glslc shaderc_util shaderc +- TEST_NAMES +- file +- resource_parse +- stage) +- + shaderc_add_asciidoc(glslc_doc_README README) + + if(SHADERC_ENABLE_INSTALL) + install(TARGETS glslc_exe + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif(SHADERC_ENABLE_INSTALL) +- +-add_subdirectory(test) +--- a/libshaderc/CMakeLists.txt ++++ b/libshaderc/CMakeLists.txt +@@ -10,18 +10,16 @@ set(SHADERC_SOURCES + src/shaderc_private.h + ) + +-add_library(shaderc STATIC ${SHADERC_SOURCES}) ++add_library(shaderc ${SHADERC_SOURCES}) + shaderc_default_compile_options(shaderc) +-target_include_directories(shaderc PUBLIC include PRIVATE ${glslang_SOURCE_DIR}) +- +-add_library(shaderc_shared SHARED ${SHADERC_SOURCES}) +-shaderc_default_compile_options(shaderc_shared) +-target_include_directories(shaderc_shared PUBLIC include PRIVATE ${glslang_SOURCE_DIR}) +-target_compile_definitions(shaderc_shared +- PRIVATE SHADERC_IMPLEMENTATION +- PUBLIC SHADERC_SHAREDLIB +-) +-set_target_properties(shaderc_shared PROPERTIES SOVERSION 1) ++target_include_directories(shaderc PUBLIC include) ++if(BUILD_SHARED_LIBS) ++ target_compile_definitions(shaderc ++ PRIVATE SHADERC_IMPLEMENTATION ++ PUBLIC SHADERC_SHAREDLIB ++ ) ++ set_target_properties(shaderc PROPERTIES OUTPUT_NAME "shaderc_shared" SOVERSION 1) ++endif() + + if(SHADERC_ENABLE_INSTALL) + install( +@@ -34,70 +32,19 @@ if(SHADERC_ENABLE_INSTALL) + DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/shaderc) + +- install(TARGETS shaderc shaderc_shared ++ install(TARGETS shaderc + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(SHADERC_ENABLE_INSTALL) + +-find_package(Threads) + set(SHADERC_LIBS +- glslang OSDependent OGLCompiler glslang ${CMAKE_THREAD_LIBS_INIT} + shaderc_util +- SPIRV # from glslang +- SPIRV-Tools ++ "CONAN_PKG::glslang" ++ "CONAN_PKG::spirv-tools" + ) + + target_link_libraries(shaderc PRIVATE ${SHADERC_LIBS}) +-target_link_libraries(shaderc_shared PRIVATE ${SHADERC_LIBS}) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc +- LINK_LIBS shaderc +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc_util/include ${glslang_SOURCE_DIR} +- ${spirv-tools_SOURCE_DIR}/include +- TEST_NAMES +- shaderc +- shaderc_cpp +- shaderc_private) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc_shared +- LINK_LIBS shaderc_shared SPIRV-Tools +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc_util/include ${glslang_SOURCE_DIR} +- ${spirv-tools_SOURCE_DIR}/include +- TEST_NAMES +- shaderc +- shaderc_cpp +- shaderc_private) +- +-shaderc_combine_static_lib(shaderc_combined shaderc) +- +-if(SHADERC_ENABLE_INSTALL) +- # Since shaderc_combined is defined as an imported library, we cannot use the +- # install() directive to install it. Install it like a normal file. +- get_target_property(generated_location shaderc_combined LOCATION) +- string(REGEX MATCH "Visual Studio .*" vs_generator "${CMAKE_GENERATOR}") +- if (NOT "${vs_generator}" STREQUAL "") +- # With Visual Studio generators, the LOCATION property is not properly +- # expanded according to the current build configuration. We need to work +- # around this problem by manually substitution. +- string(REPLACE "$(Configuration)" "\${CMAKE_INSTALL_CONFIG_NAME}" +- install_location "${generated_location}") +- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${install_location} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- else() +- install(FILES ${generated_location} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- endif() +-endif(SHADERC_ENABLE_INSTALL) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc_combined +- LINK_LIBS shaderc_combined ${CMAKE_THREAD_LIBS_INIT} +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc_util/include ${glslang_SOURCE_DIR} +- ${spirv-tools_SOURCE_DIR}/include +- TEST_NAMES +- shaderc +- shaderc_cpp) + + if(${SHADERC_ENABLE_TESTS}) + add_executable(shaderc_c_smoke_test ./src/shaderc_c_smoke_test.c) +--- a/libshaderc_spvc/CMakeLists.txt ++++ b/libshaderc_spvc/CMakeLists.txt +@@ -9,26 +9,22 @@ set(SPVC_SOURCES + src/spvc.cc + ) + +-add_library(shaderc_spvc STATIC ${SPVC_SOURCES}) ++add_library(shaderc_spvc ${SPVC_SOURCES}) + shaderc_default_compile_options(shaderc_spvc) +-target_include_directories(shaderc_spvc PUBLIC include PRIVATE ${shaderc_SOURCE_DIR}/libshaderc/include ${shaderc_SOURCE_DIR}/libshaderc_util/include ${spirv-tools_SOURCE_DIR}/include ${SPIRV-Cross_SOURCE_DIR}/..) +- +-add_library(shaderc_spvc_shared SHARED ${SPVC_SOURCES}) +-shaderc_default_compile_options(shaderc_spvc_shared) +-target_include_directories(shaderc_spvc_shared PUBLIC include PRIVATE ${shaderc_SOURCE_DIR}/libshaderc/include ${shaderc_SOURCE_DIR}/libshaderc_util/include ${spirv-tools_SOURCE_DIR}/include ${SPIRV-Cross_SOURCE_DIR}/..) +- +-target_compile_definitions(shaderc_spvc_shared +- PRIVATE SHADERC_IMPLEMENTATION +- PUBLIC SHADERC_SHAREDLIB +-) ++target_include_directories(shaderc_spvc ++ PUBLIC include ${shaderc_SOURCE_DIR}/libshaderc/include PRIVATE ${shaderc_SOURCE_DIR}/libshaderc_util/include) ++if(BUILD_SHARED_LIBS) ++ target_compile_definitions(shaderc_spvc ++ PRIVATE SHADERC_IMPLEMENTATION ++ PUBLIC SHADERC_SHAREDLIB ++ ) ++ set_target_properties(shaderc_spvc PROPERTIES OUTPUT_NAME "shaderc_spvc_shared" SOVERSION 1) ++endif() + + if (DISABLE_EXCEPTIONS) + target_compile_definitions(shaderc_spvc PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) +- target_compile_definitions(shaderc_spvc_shared PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) + endif (DISABLE_EXCEPTIONS) + +-set_target_properties(shaderc_spvc_shared PROPERTIES SOVERSION 1) +- + if(SHADERC_ENABLE_INSTALL) + install( + FILES +@@ -37,71 +33,18 @@ if(SHADERC_ENABLE_INSTALL) + DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/shaderc) + +- install(TARGETS shaderc_spvc shaderc_spvc_shared ++ install(TARGETS shaderc_spvc + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(SHADERC_ENABLE_INSTALL) + +-find_package(Threads) + set(SPVC_LIBS +- ${CMAKE_THREAD_LIBS_INIT} +- SPIRV-Tools +- SPIRV-Tools-opt +- spirv-cross-glsl +- spirv-cross-hlsl +- spirv-cross-msl ++ "CONAN_PKG::spirv-cross" ++ "CONAN_PKG::spirv-tools" + ) + + target_link_libraries(shaderc_spvc PRIVATE ${SPVC_LIBS}) +-target_link_libraries(shaderc_spvc_shared PRIVATE ${SPVC_LIBS}) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc +- LINK_LIBS shaderc_spvc +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc/include ${SPIRV-Cross_SOURCE_DIR}/.. +- TEST_NAMES +- spvc +- spvc_cpp +- spvc_webgpu +- spvc_webgpu_cpp) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc_shared +- LINK_LIBS shaderc_spvc_shared SPIRV-Tools SPIRV-Tools-opt +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc/include ${SPIRV-Cross_SOURCE_DIR}/.. +- TEST_NAMES +- spvc +- spvc_cpp +- spvc_webgpu +- spvc_webgpu_cpp) +- +-shaderc_combine_static_lib(shaderc_spvc_combined shaderc_spvc) +- +-if(SHADERC_ENABLE_INSTALL) +- # Since shaderc_combined is defined as an imported library, we cannot use the +- # install() directive to install it. Install it like a normal file. +- get_target_property(generated_location shaderc_spvc_combined LOCATION) +- string(REGEX MATCH "Visual Studio .*" vs_generator "${CMAKE_GENERATOR}") +- if (NOT "${vs_generator}" STREQUAL "") +- # With Visual Studio generators, the LOCATION property is not properly +- # expanded according to the current build configuration. We need to work +- # around this problem by manually substitution. +- string(REPLACE "$(Configuration)" "\${CMAKE_INSTALL_CONFIG_NAME}" +- install_location "${generated_location}") +- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${install_location} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- else() +- install(FILES ${generated_location} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- endif() +-endif(SHADERC_ENABLE_INSTALL) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc_spvc_combined +- LINK_LIBS shaderc_spvc_combined ${CMAKE_THREAD_LIBS_INIT} shaderc_util +- INCLUDE_DIRS include ${shaderc_SOURCE_DIR}/libshaderc/include ${spirv-tools_SOURCE_DIR}/include +- TEST_NAMES +- spvc +- spvc_cpp) + + if(${SHADERC_ENABLE_TESTS}) + add_executable(spvc_c_smoke_test ./src/spvc_smoke_test_util.c ./src/spvc_c_smoke_test.c) +--- a/libshaderc_util/CMakeLists.txt ++++ b/libshaderc_util/CMakeLists.txt +@@ -24,25 +24,20 @@ add_library(shaderc_util STATIC + + shaderc_default_compile_options(shaderc_util) + target_include_directories(shaderc_util +- PUBLIC include PRIVATE ${glslang_SOURCE_DIR}) ++ PUBLIC include) + + find_package(Threads) +-target_link_libraries(shaderc_util PRIVATE +- glslang OSDependent OGLCompiler HLSL glslang SPIRV +- SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT}) +- +-shaderc_add_tests( +- TEST_PREFIX shaderc_util +- LINK_LIBS shaderc_util +- TEST_NAMES +- counting_includer +- string_piece +- format +- file_finder +- io +- message +- mutex +- version_profile) ++target_link_libraries(shaderc_util PUBLIC ++ CONAN_PKG::glslang ++ CONAN_PKG::spirv-tools ++ ${CMAKE_THREAD_LIBS_INIT}) ++ ++if(SHADERC_ENABLE_INSTALL AND NOT BUILD_SHARED_LIBS) ++ install(TARGETS shaderc_util ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++endif(SHADERC_ENABLE_INSTALL) + + if(${SHADERC_ENABLE_TESTS}) + target_include_directories(shaderc_util_counting_includer_test +@@ -51,15 +46,6 @@ if(${SHADERC_ENABLE_TESTS}) + PRIVATE ${glslang_SOURCE_DIR}) + endif() + +-shaderc_add_tests( +- TEST_PREFIX shaderc_util +- LINK_LIBS shaderc_util +- INCLUDE_DIRS +- ${glslang_SOURCE_DIR} +- ${spirv-tools_SOURCE_DIR}/include +- TEST_NAMES +- compiler) +- + # This target copies content of testdata into the build directory. + add_custom_target(testdata COMMAND + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/testdata/copy-to-build.cmake +--- a/spvc/CMakeLists.txt ++++ b/spvc/CMakeLists.txt +@@ -1,8 +1,8 @@ + add_executable(spvc_exe src/main.cc) + shaderc_default_compile_options(spvc_exe) +-target_include_directories(spvc_exe PRIVATE ${shaderc_SOURCE_DIR}/libshaderc/include ${spirv-tools_SOURCE_DIR}/include) ++target_include_directories(spvc_exe PRIVATE ${shaderc_SOURCE_DIR}/libshaderc/include) + set_target_properties(spvc_exe PROPERTIES OUTPUT_NAME spvc) +-target_link_libraries(spvc_exe PRIVATE shaderc_spvc shaderc_util) ++target_link_libraries(spvc_exe PRIVATE shaderc_spvc shaderc_util CONAN_PKG::spirv-tools) + add_dependencies(spvc_exe build-version) + + shaderc_add_asciidoc(spvc_doc_README README) +--- a/utils/update_build_version.py ++++ b/utils/update_build_version.py +@@ -114,12 +114,12 @@ def get_version_string(project, directory): + + + def main(): +- if len(sys.argv) != 4: +- print('usage: {} '.format( ++ if len(sys.argv) != 2: ++ print('usage: {} '.format( + sys.argv[0])) + sys.exit(1) + +- projects = ['shaderc', 'spirv-tools', 'glslang'] ++ projects = ['shaderc'] + new_content = ''.join([ + '"{}\\n"\n'.format(get_version_string(p, d)) + for (p, d) in zip(projects, sys.argv[1:]) diff --git a/recipes/shaderc/all/patches/2019.0/fix-spvc.patch b/recipes/shaderc/all/patches/2019.0/fix-spvc.patch new file mode 100644 index 0000000000..682a95ac5d --- /dev/null +++ b/recipes/shaderc/all/patches/2019.0/fix-spvc.patch @@ -0,0 +1,24 @@ +--- a/libshaderc_spvc/src/spvc.cc ++++ b/libshaderc_spvc/src/spvc.cc +@@ -15,9 +15,9 @@ + #include "shaderc/spvc.h" + + #include "libshaderc_util/exceptions.h" +-#include "spirv-cross/spirv_glsl.hpp" +-#include "spirv-cross/spirv_hlsl.hpp" +-#include "spirv-cross/spirv_msl.hpp" ++#include "spirv_glsl.hpp" ++#include "spirv_hlsl.hpp" ++#include "spirv_msl.hpp" + #include "spirv-tools/libspirv.hpp" + #include "spirv-tools/optimizer.hpp" + +@@ -169,7 +169,7 @@ size_t shaderc_spvc_compile_options_set_for_fuzzing( + shaderc_spvc_compile_options_t options, const uint8_t* data, size_t size) { + if (!data || size < sizeof(*options)) return 0; + +- memcpy(options, data, sizeof(*options)); ++ memcpy(static_cast(options), data, sizeof(*options)); + return sizeof(*options); + } + diff --git a/recipes/shaderc/all/test_package/CMakeLists.txt b/recipes/shaderc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..492695489b --- /dev/null +++ b/recipes/shaderc/all/test_package/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME}_shaderc_c test_package_shaderc.c) +target_link_libraries(${PROJECT_NAME}_shaderc_c ${CONAN_LIBS}) + +add_executable(${PROJECT_NAME}_shaderc_cpp test_package_shaderc.cpp) +target_link_libraries(${PROJECT_NAME}_shaderc_cpp ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME}_shaderc_cpp PROPERTY CXX_STANDARD 11) + +if(SHADERC_WITH_SPVC) + add_executable(${PROJECT_NAME}_spvc_c test_package_spvc.c) + target_link_libraries(${PROJECT_NAME}_spvc_c ${CONAN_LIBS}) + + add_executable(${PROJECT_NAME}_spvc_cpp test_package_spvc.cpp) + target_link_libraries(${PROJECT_NAME}_spvc_cpp ${CONAN_LIBS}) + set_property(TARGET ${PROJECT_NAME}_spvc_cpp PROPERTY CXX_STANDARD 11) +endif() diff --git a/recipes/shaderc/all/test_package/conanfile.py b/recipes/shaderc/all/test_package/conanfile.py new file mode 100644 index 0000000000..25605eb0a0 --- /dev/null +++ b/recipes/shaderc/all/test_package/conanfile.py @@ -0,0 +1,32 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.definitions["SHADERC_WITH_SPVC"] = self.options["shaderc"].spvc + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + # Test programs consuming shaderc lib + bin_path_shaderc_c = os.path.join("bin", "test_package_shaderc_c") + self.run(bin_path_shaderc_c, run_environment=True) + bin_path_shaderc_cpp = os.path.join("bin", "test_package_shaderc_cpp") + self.run(bin_path_shaderc_cpp, run_environment=True) + # Test glslc executable + in_glsl_name = os.path.join(self.source_folder, "test_package.vert") + spv_name = "test_package.spv" + self.run("glslc \"{0}\" -o {1}".format(in_glsl_name, spv_name), run_environment=True) + + if self.options["shaderc"].spvc: + # Test programs consuming shaderc_spvc lib + bin_path_spvc_c = os.path.join("bin", "test_package_spvc_c") + self.run(bin_path_spvc_c, run_environment=True) + bin_path_spvc_cpp = os.path.join("bin", "test_package_spvc_cpp") + self.run(bin_path_spvc_cpp, run_environment=True) diff --git a/recipes/shaderc/all/test_package/test_package.vert b/recipes/shaderc/all/test_package/test_package.vert new file mode 100644 index 0000000000..8f349eebab --- /dev/null +++ b/recipes/shaderc/all/test_package/test_package.vert @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 inPosition; + +void main() { + gl_Position = vec4(inPosition, 0.0, 1.0); +} diff --git a/recipes/shaderc/all/test_package/test_package_shaderc.c b/recipes/shaderc/all/test_package/test_package_shaderc.c new file mode 100644 index 0000000000..6a83dd0f7a --- /dev/null +++ b/recipes/shaderc/all/test_package/test_package_shaderc.c @@ -0,0 +1,8 @@ +#include + +int main() { + shaderc_compiler_t shaderc_compiler = shaderc_compiler_initialize(); + shaderc_compiler_release(shaderc_compiler); + + return 0; +} diff --git a/recipes/shaderc/all/test_package/test_package_shaderc.cpp b/recipes/shaderc/all/test_package/test_package_shaderc.cpp new file mode 100644 index 0000000000..d6defefea4 --- /dev/null +++ b/recipes/shaderc/all/test_package/test_package_shaderc.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + shaderc::Compiler compiler; + shaderc::CompileOptions compile_options; + + return 0; +} diff --git a/recipes/shaderc/all/test_package/test_package_spvc.c b/recipes/shaderc/all/test_package/test_package_spvc.c new file mode 100644 index 0000000000..c9fc709f30 --- /dev/null +++ b/recipes/shaderc/all/test_package/test_package_spvc.c @@ -0,0 +1,8 @@ +#include + +int main() { + shaderc_spvc_compiler_t shaderc_spvc_compiler = shaderc_spvc_compiler_initialize(); + shaderc_spvc_compiler_release(shaderc_spvc_compiler); + + return 0; +} diff --git a/recipes/shaderc/all/test_package/test_package_spvc.cpp b/recipes/shaderc/all/test_package/test_package_spvc.cpp new file mode 100644 index 0000000000..40978d50d1 --- /dev/null +++ b/recipes/shaderc/all/test_package/test_package_spvc.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + shaderc_spvc::Compiler compiler; + shaderc_spvc::CompileOptions compile_options; + + return 0; +} diff --git a/recipes/shaderc/config.yml b/recipes/shaderc/config.yml new file mode 100644 index 0000000000..038d99956a --- /dev/null +++ b/recipes/shaderc/config.yml @@ -0,0 +1,3 @@ +versions: + "2019.0": + folder: all