Cleanup for the cmake file.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
eb3e174877
commit
4f5ae70634
|
@ -1,43 +1,52 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
project(Arbutils)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||
# Enable all warnings, and make them error when occurring.
|
||||
add_compile_options(-Wall -Wextra -Werror)
|
||||
# We like new stuff, so set the c++ standard to c++20.
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
if (WINDOWS)
|
||||
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||
endif (WINDOWS)
|
||||
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
||||
option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
|
||||
option(TESTS "Whether the test executable should be build as well." OFF)
|
||||
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp" "CInterface/*.cpp")
|
||||
# Set whether we want a static or shared library.
|
||||
set(LIBTYPE STATIC)
|
||||
if (SHARED)
|
||||
set(LIBTYPE SHARED src/StringView.hpp src/String/BasicStringView.hpp src/String/StringViewLiteral.hpp CInterface/Random.cpp)
|
||||
endif(SHARED)
|
||||
set(LIBTYPE SHARED)
|
||||
endif (SHARED)
|
||||
|
||||
# Grab all cpp and hpp files in our source directories.
|
||||
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp" "CInterface/*.cpp")
|
||||
add_library(Arbutils ${LIBTYPE} ${SRC_FILES})
|
||||
|
||||
|
||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||
if (NOT DEFINED CONAN_EXPORTED)
|
||||
if (TESTS)
|
||||
# If we want a tests executable, grab all tests source files
|
||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||
# And create an executable from it. Also include catch.hpp.
|
||||
add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp)
|
||||
# And finally link the library to the executable.
|
||||
target_link_libraries(ArbutilsTests Arbutils)
|
||||
endif()
|
||||
# Add a compilation definition to the code that we are building a test build.
|
||||
target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD)
|
||||
endif ()
|
||||
|
||||
# If we are building for Windows we need to set some specific variables.
|
||||
if (WINDOWS)
|
||||
MESSAGE(WARNING, "Using Windows Build.")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
|
||||
# Add a definition for the compiler, so we can use it in C++ as well.
|
||||
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||
# -m64: Build a 64 bit library
|
||||
add_compile_options(-m64)
|
||||
endif (WINDOWS)
|
||||
|
||||
# If we want to link the C and C++ library statically, link those as well.
|
||||
if (STATICC)
|
||||
target_link_libraries(Arbutils -static-libgcc -static-libstdc++)
|
||||
if (NOT DEFINED CONAN_EXPORTED)
|
||||
target_link_libraries(ArbutilsTests -static-libgcc -static-libstdc++)
|
||||
endif()
|
||||
endif(STATICC)
|
||||
|
||||
if (NOT DEFINED CONAN_EXPORTED)
|
||||
target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD)
|
||||
endif()
|
||||
|
||||
# If we aren't building for Windows, also include an option for installing on unix.
|
||||
if (NOT WINDOWS)
|
||||
install(TARGETS Arbutils
|
||||
CONFIGURATIONS Release
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace ArbUt {
|
|||
public:
|
||||
[[nodiscard]] inline constexpr size_t Length() const noexcept { return _length; }
|
||||
[[nodiscard]] inline constexpr uint32_t GetHash() const noexcept { return _hash; }
|
||||
[[nodiscard]] inline constexpr std::size_t operator()(BasicStringView const& s) const noexcept { return _hash; }
|
||||
[[nodiscard]] inline constexpr std::size_t operator()() const noexcept { return _hash; }
|
||||
[[nodiscard]] inline constexpr operator uint32_t() const noexcept { return _hash; }
|
||||
[[nodiscard]] inline constexpr bool operator==(const BasicStringView& rhs) const noexcept {
|
||||
return _hash == rhs._hash;
|
||||
|
|
Loading…
Reference in New Issue