-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include errors #142
Comments
NOTE: |
Thank you, I did not see that! I still have the problem that the includes to the libraries seem to be broken. |
I think this is related to CPM, because I was able to fix the SDL include issue.
|
why not use the |
That seems to work, I still cannot figure out glew, spdlog and glm.
|
I dit it here the same way: https://github.com/ClausKlein/cxx.simplelog/blob/73365bd126ca49ab7bd02e2bd53738f296cdb83a/CMakeLists.txt#L74 |
Spdlog seems to work now, just GLM and glew has issues. I use |
What du you want With empty Option CMAKE_INSTALL_PREFIX |
Nothing, I don't get what I miss for GLM and Glew to work. |
Do |
HINT: use the |
This build and install the targets on my iMac, but the exported cmake_minimum_required(VERSION 3.14...3.26 FATAL_ERROR)
# ---- Project ----
# Note: update this to your new project's name and version
project(
Arcanelords
VERSION 0.1
LANGUAGES CXX
)
set(OpenGL_GL_PREFERENCE "GLVND")
# ---- Include guards ----
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(cmake/CPM.cmake)
# PackageProject.cmake will be used to make our target installable
CPMAddPackage("gh:TheLartians/[email protected]")
CPMAddPackage(
NAME fmt
GIT_TAG 8.0.1
GITHUB_REPOSITORY fmtlib/fmt
OPTIONS "FMT_INSTALL YES" # create an installable target
)
CPMAddPackage(
NAME SDL2
GIT_TAG release-2.0.16
GITHUB_REPOSITORY libsdl-org/SDL
)
CPMAddPackage(
NAME glm
GITHUB_REPOSITORY g-truc/glm
GIT_TAG 0.9.9.8
SOURCE_SUBDIR glm
OPTIONS "GLM_STATIC_LIBRARY_ENABLE"
)
CPMAddPackage(
NAME spdlog
GITHUB_REPOSITORY gabime/spdlog
GIT_TAG v1.9.2
OPTIONS "SPDLOG_INSTALL YES" "SPDLOG_FMT_EXTERNAL YES"
)
# GLFW
CPMAddPackage(
NAME glew
GITHUB_REPOSITORY nigels-com/glew
GIT_TAG glew-2.2.0
SOURCE_SUBDIR glew
OPTIONS "GLEW_STATIC YES"
# XXX "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}"
)
CPMAddPackage(
NAME EnTT
VERSION 3.8.1
GITHUB_REPOSITORY skypjack/entt
)
# ---- Add source files ----
# Note: globbing sources is considered bad practice as CMake's generators may not detect new files
# automatically. Keep that in mind when changing files, or explicitly mention them here.
# XXX file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
# XXX file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
# ---- Create library ----
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
# target:
add_library(${PROJECT_NAME} INTERFACE)
# XXX add_library(${PROJECT_NAME} ${headers} ${sources})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(${PROJECT_NAME} INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
# Link dependencies
target_link_libraries(${PROJECT_NAME} INTERFACE SDL2 glew fmt::fmt OpenGL32 spdlog::spdlog EnTT)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
#FIXME: $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)
# ---- Create an installable target ----
# this allows users to install and find the library via `find_package()`.
# the location where the project's version header will be placed should match the project's regular
# header paths
string(TOLOWER ${PROJECT_NAME}}/version.h VERSION_HEADER_LOCATION)
packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE ${PROJECT_NAME}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
VERSION_HEADER "${PROJECT_NAME}version.h"
EXPORT_HEADER "${PROJECT_NAME}/source/export.h"
COMPATIBILITY SameMajorVersion
DEPENDENCIES "fmt 8.0" "SDL2 2.0" "glm 0.9" "spdlog 1.9" "entt 3.8"
) |
|
I tried to add multiple libraries to this template project, but all my library includes seem to be failing (eg: #include <SDL.h>
). I am not sure if I did something wrong. Could you take a look for me? The other problem I had when I tried to use spdlog with the
option, the spdlog was not able to find fmt which was downloaded by CPMAddPackage already.
Here is my CMakeList.txt:
The text was updated successfully, but these errors were encountered: