C:\mangetsu\build>cmake -DBUILD_GUI=On ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.29.30146.0
-- The CXX compiler identification is MSVC 19.29.30146.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: opengl32
-- Found PkgConfig: C:/Program Files/CMake/bin/pkg-config.exe (found version "0.26")
-- Checking for module 'glfw3'
-- No package 'glfw3' found
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
CMakeLists.txt:37 (pkg_check_modules)
I tried to install it, but cmake doesn't seem to find it.
sudo apt install -y build-essential cmake zlib1g-dev libssl-dev
sudo apt install -y libopengl-dev libglfw3-dev
I'm trying to build a "program" using cmake, but I'm having problems since it can't find the necessary packages, even though I already have them installed.
The problem is that it only teaches how to install on linux, but on windows I had to do it manually.
The cmake lists:
cmake_minimum_required(VERSION 3.1)
project(mangetsu LANGUAGES C CXX)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/;/usr/local/")
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif ()
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf-4 -g3 -g -rdynamic")
set(GCC_OPTIMIZATION "-O0")
endif ()
set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Werror -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=pragmas -Wno-error=unused-local-typedefs")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_OPTIMIZATION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
# Put UI stuff behind a build flag so that people don't have to mess around
# with deps as much by default
if (${BUILD_GUI})
# OpenGL
include(FindOpenGL)
include_directories(${OPENGL_INCLUDE_DIRS})
# Glfw for windowing
find_package(PkgConfig)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
pkg_check_modules(PC_LIBGLFW REQUIRED glfw3)
include_directories(${PC_LIBGLFW_INCLUDE_DIRS})
endif()
include_directories(include)
# Json library
include_directories(vendor/json)
# Only build imgui lib if UI is enabled
if (${BUILD_GUI})
include_directories(vendor/imgui/)
add_library(imgui
STATIC
vendor/imgui/imgui.cpp
vendor/imgui/imgui_draw.cpp
vendor/imgui/imgui_impl_glfw.cpp
vendor/imgui/imgui_impl_opengl2.cpp
vendor/imgui/imgui_tables.cpp
vendor/imgui/imgui_widgets.cpp
)
set_target_properties(imgui
PROPERTIES POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(imgui
${OPENGL_LIBRARIES}
${PC_LIBGLFW_LIBRARIES}
)
endif()
add_library(mg_util
src/util/fs.cpp
)
add_library(mg_data
src/data/mzp.cpp
src/data/mzx.cpp
src/data/mrg.cpp
src/data/nam.cpp
src/data/nxx.cpp
)
target_link_libraries(mg_data
z
mg_util
)
add_executable(nxx_decompress
src/tools/nxx_decompress.cpp
)
target_link_libraries(nxx_decompress
mg_data
)
add_executable(nxgx_compress
src/tools/nxgx_compress.cpp
)
target_link_libraries(nxgx_compress
mg_data
)
add_executable(mzx_decompress
src/tools/mzx_decompress.cpp
)
target_link_libraries(mzx_decompress
mg_data
)
add_executable(mzx_compress
src/tools/mzx_compress.cpp
)
target_link_libraries(mzx_compress
mg_data
)
add_executable(mzp_info
src/tools/mzp_info.cpp
)
target_link_libraries(mzp_info
mg_data
)
add_executable(mzp_extract
src/tools/mzp_extract.cpp
)
target_link_libraries(mzp_extract
mg_data
stdc++fs
)
add_executable(mzp_compress
src/tools/mzp_compress.cpp
)
target_link_libraries(mzp_compress
mg_data
)
add_executable(nam_read
src/tools/nam_read.cpp
)
target_link_libraries(nam_read
mg_data
)
if (${BUILD_GUI})
add_executable(data_explorer
src/tools/data_explorer.cpp
)
target_link_libraries(data_explorer
mg_data
imgui
)
endif()
add_executable(script_text_to_content_json
src/tools/script_text_to_content_json.cpp
)
target_link_libraries(script_text_to_content_json
mg_data
ssl
crypto
)
add_executable(repack_script_text_translation
src/tools/repack_script_text_translation.cpp
)
target_link_libraries(repack_script_text_translation
mg_data
ssl
crypto
)
add_executable(mrg_extract
src/tools/mrg_extract.cpp
)
target_link_libraries(mrg_extract
mg_data
stdc++fs
)
add_executable(mrg_pack
src/tools/mrg_pack.cpp
)
target_link_libraries(mrg_pack
mg_data
stdc++fs
)
add_executable(mrg_info
src/tools/mrg_info.cpp
)
target_link_libraries(mrg_info
mg_data
stdc++fs
)
add_executable(mrg_replace
src/tools/mrg_replace.cpp
)
target_link_libraries(mrg_replace
mg_data
stdc++fs
)
For some reason, tarballs available on https://www.glfw.org/download.html for Windows don't contain pkgconfig & CMake config files. In a sense these packages are illformed.
I advice to build & install glfw from source or use a package manager (conan or vcpkg for example on Windows).
Then in your CMakeLists.txt:
CMake configuration:
PS: your CMakeLists has many more issues unrelated to your question (non-portable way to do several things: compile flags specific to gcc, fragile link to hardcoded unix lib names of zlib & openssl, link to stdc++fs while it doesn't make sense and can't work for many compilers, an absolute path hardcoded in CMAKE_MODULE_PATH).