I have small frequently modified *.pri source-libraries, purpose of those pri's is to add headers and sources, do aux tasks like copy file. Those libraries are at same or higher directory level than the project that will use them and must have access to parent project variables (e.g ANDROID_PACKAGE_SOURCE_DIR)
example of *.pri:
#AnFeature/AnFeature.pri
HEADERS = $$PWD/anfeature.h
SOURCES = $$PWD/anfeature.cpp
INCLUDEPATH = $$PWD
OTHER_FILES = $$PWD/android/src/example/anfeature/anfeature.java
QMAKE_POST_LINK = $$QMAKE_COPY_DIR $$shell_path($$PWD/android/src/example/anfeature) $$shell_path($$ANDROID_PACKAGE_SOURCE_DIR/src/example/anfeature)
Looking how to implement that kind of stuff via CMake 3.19 or newer
CodePudding user response:
HEADERS
andSOURCES
are just variables, so you can use target_sources. You can even set the source property on targets using set_property.For
INCLUDEPATH
, you can use target_include_directories. Or simple specifying your library dependency after finding it with find_package using target_link_librariesFor
OTHER_FILES
, you can just again set a cmake variable if you really need to.For running custom commands, like
QMAKE_POST_LINK
does, you can use add_custom_command.