Skip to content

Can't set PCRE2_BUILD_TESTS and PCRE2_BUILD_PCRE2GREP in CMake when added as dependency #267

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

Closed
mcfriend99 opened this issue Jun 14, 2023 · 5 comments

Comments

@mcfriend99
Copy link

I'm using the following CMake section to build pcre2 as a project dependency on Ubuntu 20.04 and MacoOS monterey.

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PCRE2_USE_STATIC_LIBS ON)
set(PCRE2_BUILD_TESTS OFF)
set(PCRE2_BUILD_PCRE2GREP OFF)
include(FetchContent)
FetchContent_Declare(pcre2
		URL      https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz
		URL_HASH SHA256=c33b418e3b936ee3153de2c61cc638e7e4fe3156022a5c77d0711bcbb9d64f1f
		)
FetchContent_MakeAvailable(pcre2)

if(NOT pcre2_POPULATED)
	FetchContent_Populate(pcre2)
	add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BUILD_DIR})
endif()

However, PCRE2_BUILD_TESTS and PCRE2_BUILD_PCRE2GREP are still showing and behaving as ON in cmake configuration and build

I've also tried with ubuntu-latest and macos-latest on Github and I'm still getting the following errors on ctest.

The following tests FAILED:
[173](https://github.com/user/repo/actions/runs/xxx/jobs/yyy#step:5:174)
	 69 - pcre2_test (Failed)
[174](https://github.com//user/repo/actions/runs/xxx/jobs/yyy#step:5:175)
	 70 - pcre2_grep_test (Failed)
[175](https://github.com/blade-lang//user/repo/runs/xxx/jobs/yyy#step:5:176)
	 71 - pcre2posix_test (Not Run)

Same error locally. What could I be doing wrong??

@mcfriend99
Copy link
Author

I've even tried disabling install using

macro(install)
    _install(${ARGN})
endmacro()

Still the same thing.

@mcfriend99
Copy link
Author

Looks like #266 is trying to address this problem. Any luck on getting this merged??

@PhilipHazel
Copy link
Collaborator

As you probably noticed, there is a flurry of activity surrounding CMake at the moment, especially #260. I know nothing about CMake, so I was holding off merging anything until it all settles down. @carenas, should I get on with merging #266 as is requested here?

@carenas
Copy link
Contributor

carenas commented Jun 14, 2023

#265 and #266 are independent of #260 and can be applied now, there is sadly no warranty it will actually solve this use case though, but can't hurt

@mcfriend99
Copy link
Author

For others that may end up here in the future, adding set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) before other declarations fixed it for me. Like this:

set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PCRE2_USE_STATIC_LIBS ON)
set(PCRE2_BUILD_TESTS OFF)
set(PCRE2_BUILD_PCRE2GREP OFF)
include(FetchContent)
FetchContent_Declare(pcre2
		URL      https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz
		URL_HASH SHA256=c33b418e3b936ee3153de2c61cc638e7e4fe3156022a5c77d0711bcbb9d64f1f
		)
FetchContent_MakeAvailable(pcre2)

if(NOT pcre2_POPULATED)
	FetchContent_Populate(pcre2)
	add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BUILD_DIR})
endif()

I'll be closing for now since there is a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants