Skip to content
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

[CMake] Restore old way of importing Notcurses into a cmake project #1149

Merged
merged 1 commit into from
Nov 29, 2020

Conversation

grendello
Copy link
Collaborator

Partially reverts: c5c9432
Context: #1146

The above commit implemented the much more convenient way of finding and
using a package from CMake, however it broke compatibility with the way
id had been before, which defined various Notcurses_* variables.

Revert the Notcurses component to the old way and add support for
Notcurses++ in the same fashion.

Perhaps one day we should think of implementing find_package support
by way of a module, which should make it possible to have the cake and
eat the cake. One day.

Partially reverts: c5c9432
Context: dankamongmen#1146

The above commit implemented the much more convenient way of finding and
using a package from CMake, however it broke compatibility with the way
id had been before, which defined various `Notcurses_*` variables.

Revert the `Notcurses` component to the old way and add support for
`Notcurses++` in the same fashion.

Perhaps one day we should think of implementing `find_package` support
by way of a module, which should make it possible to have the cake and
eat the cake. One day.
@dankamongmen
Copy link
Owner

Wait, I thought the old definitions were coming from pkg-config. If I switched over to your new CMakey solution, yeah, I have to update my references, but that's part of the cost. Or am I missing something?

I just wanted to make sure nothing broke if one was using a pure pkg-config approach, like growlight is for instance. And so far as I can tell, nothing does.

@grendello
Copy link
Collaborator Author

Wait, I thought the old definitions were coming from pkg-config. If I switched over to your new CMakey solution, yeah, I have to update my references, but that's part of the cost. Or am I missing something?

They come from the *Config.cmake files we generate, pkg_config isn't apparently involved. Incidentally, I think the files we generate are actually broken, here's what I get:

####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was NotcursesConfig.cmake.in                            ########

get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

macro(set_and_check _var _file)
  set(${_var} "${_file}")
  if(NOT EXISTS "${_file}")
    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
  endif()
endmacro()

macro(check_required_components _NAME)
  foreach(comp ${${_NAME}_FIND_COMPONENTS})
    if(NOT ${_NAME}_${comp}_FOUND)
      if(${_NAME}_FIND_REQUIRED_${comp})
        set(${_NAME}_FOUND FALSE)
      endif()
    endif()
  endforeach()
endmacro()

####################################################################################
set(Notcurses_DIR "")

# Compute paths
get_filename_component(Notcurses_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(Notcurses_INCLUDE_DIRS "")
set(Notcurses_LIBRARY_DIRS "")

set(Notcurses_LIBRARIES -lnotcurses)

Note the *_DIRS variables are empty.

I just wanted to make sure nothing broke if one was using a pure pkg-config approach, like growlight is for instance. And so far as I can tell, nothing does.

Pure pkg-config would look like:

pkg_check_modules(NOTCURSES REQUIRED notcurses>=2.0.8)

find_package might fall back to pkg-config if it doesn't find any *Config.cmake etc files for a package - but in our case it does find them, so I doubt it goes any farther than that.

@dankamongmen
Copy link
Owner

[deletia]

avast! sacre bleu!

@dankamongmen dankamongmen merged commit 9135663 into dankamongmen:master Nov 29, 2020
@dankamongmen
Copy link
Owner

https://www.youtube.com/watch?v=jAotm74ek4c @grendello

@dankamongmen
Copy link
Owner

/""\

@grendello
Copy link
Collaborator Author

I wonder how come it works for you in glowlight - on my system, with those files in place, Notcurses does get detected but the build fails because lib path is empty, so is include path.

@grendello grendello deleted the cmake-rev branch November 29, 2020 11:44
@dankamongmen
Copy link
Owner

probably because i've got the debian libnotcurses-dev package installed, so it's in standard locations

@grendello
Copy link
Collaborator Author

That might be it, I don't have it installed (on purpose). So maybe we can switch to the namespace::component system after all without breaking backward compatibility?

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

Successfully merging this pull request may close these issues.

2 participants