Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ jobs:
- run:
name: Install packages
command: |
choco install cmake.portable ninja
choco install cmake.portable ninja pkgconfiglite
- run:
name: Add python to bash path
command: echo "export PATH=\"$PATH:/c/Python27amd64/\"" >> $BASH_ENV
Expand All @@ -455,6 +455,7 @@ jobs:
command: |
brew list cmake || brew install cmake
brew list python3 || brew install python3
brew list pkg-config || brew install pkg-config
- checkout
- build
# note we do *not* build all libraries and freeze the cache; as we run
Expand Down
13 changes: 13 additions & 0 deletions cmake/Modules/Platform/Emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ if (NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()

set(_em_pkgconfig_libdir "${EMSCRIPTEN_SYSROOT}/local/lib/pkgconfig" "${EMSCRIPTEN_SYSROOT}/lib/pkgconfig")
if("${CMAKE_VERSION}" VERSION_LESS "3.20")
file(TO_NATIVE_PATH "${_em_pkgconfig_libdir}" _em_pkgconfig_libdir)
if(CMAKE_HOST_UNIX)
string(REPLACE ";" ":" _em_pkgconfig_libdir "${_em_pkgconfig_libdir}")
string(REPLACE "\\ " " " _em_pkgconfig_libdir "${_em_pkgconfig_libdir}")
endif()
else()
cmake_path(CONVERT "${_em_pkgconfig_libdir}" TO_NATIVE_PATH_LIST _em_pkgconfig_libdir)
endif()
set(ENV{PKG_CONFIG_LIBDIR} "${_em_pkgconfig_libdir}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should also set PKG_CONFIG_SYSROOT_DIR here? (doesn't have to be part of this change).

Copy link
Contributor Author

@nthirtyone nthirtyone May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to leave it out for now. We'd want to get consistent behaviour for CMake and building.py and PKG_CONFIG_SYSROOT_DIR can easily become a journey on its own (LIBDIR is good enough for most use cases, and SYSROOT affects only the PATH, not LIBDIR).

unset(_em_pkgconfig_libdir)

option(EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES "If set, static library targets generate LLVM bitcode files (.bc). If disabled (default), UNIX ar archives (.a) are generated." OFF)
if (EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES)
message(FATAL_ERROR "EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES is not compatible with the llvm backend")
Expand Down
14 changes: 14 additions & 0 deletions tests/cmake/find_pkg_config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.0)
project(find_pkg_config)

message(STATUS "PKG_CONFIG_LIBDIR: $ENV{PKG_CONFIG_LIBDIR}")

find_package(PkgConfig REQUIRED QUIET)
if (NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR "Could not find pkg-config executable!")
endif()

message(STATUS "Check that all .pc files shipped with Emscripten can be located correctly")
pkg_check_modules(EGL REQUIRED egl)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment here: Emscripten ships .pc files for egl/glesv2/sdl. Check that they can all be located correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a message explaining what the script is trying to do. I reworded it a bit to not contain the list of packages, so that adding a new package won't require modifying the message on top of everything else. I guess we could just go with a full-pledged list and then iterate, create some nice message and so on, but I feel like that'd be an overkill for a test and I'd rather have it dumb simple.

pkg_check_modules(GLESV2 REQUIRED glesv2)
pkg_check_modules(SDL2 REQUIRED sdl)
8 changes: 8 additions & 0 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,14 @@ def test_cmake_find_modules(self):
self.assertContained('AL_VERSION: 1.1', output)
self.assertContained('SDL version: 2.0.', output)

def test_cmake_find_pkg_config(self):
if not utils.which('pkg-config'):
self.fail('pkg-config is required to run this test')
out = self.run_process([EMCMAKE, 'cmake', test_file('cmake/find_pkg_config')], stdout=PIPE).stdout
libdir = shared.Cache.get_sysroot_dir('local', 'lib', 'pkgconfig')
libdir += os.path.pathsep + shared.Cache.get_sysroot_dir('lib', 'pkgconfig')
self.assertContained('PKG_CONFIG_LIBDIR: ' + libdir, out)

def test_system_include_paths(self):
# Verify that all default include paths are within `emscripten/system`

Expand Down