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

Add commands for retrieving include and lib directories #290

Open
nop144d opened this issue Dec 13, 2022 · 2 comments
Open

Add commands for retrieving include and lib directories #290

nop144d opened this issue Dec 13, 2022 · 2 comments

Comments

@nop144d
Copy link

nop144d commented Dec 13, 2022

Here is the main issue: https://gist.github.com/gdianaty/33c3190a217cd188ea43cd4b06618ba9

When building via Visual Studio, CMAKE_JS_INC and CMAKE_JS_LIB directories are needed to be known. People call "print-configure" and try to get those in various ways from the output. Please add separate commands to get those in order to avoid workarounds like this.

@Julusian
Copy link
Collaborator

This is implemented in v7.1.0.

There can sometimes be logging included in the output, but setting that to error level should hide anything: cmake-js -l error print-cmakejs-include

Could you provide some example of how to set this up for an ide, so that I can include it in some documentation?
So far I have only verified that they work when run manually, and by mangling my CMakeLists.txt to manually execute these commands instead of using the builtin variables:

execute_process(COMMAND cmake-js -l error print-cmakejs-src OUTPUT_VARIABLE CMAKE_JS_SRC2 OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ..)
execute_process(COMMAND cmake-js -l error print-cmakejs-include OUTPUT_VARIABLE CMAKE_JS_INC2 OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ..)
execute_process(COMMAND cmake-js -l error print-cmakejs-lib OUTPUT_VARIABLE CMAKE_JS_LIB2 OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ..)

include_directories(${CMAKE_JS_INC2})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES} ${CMAKE_JS_SRC2})
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB2})

@nop144d
Copy link
Author

nop144d commented Dec 16, 2022

Thank you!

Yes, that's also how I do it, don't know how else it could be done as those somehow need to be added to target_include_directories() and target_link_libraries(). Maybe separating this part into a helper cmake module (something I called cmake-js-helper.cmake) would make CMakeLists.txt somewhat clear, but that's just it I think.

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

2 participants