-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: Partial fix for FetchContent #36
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
# Make CMake run the scripts for creating the input files | ||
|
||
# The output directory of the module files | ||
set(LIB_MOD_DIR "${CMAKE_CURRENT_BINARY_DIR}/modules") | ||
if(NOT EXISTS "${LIB_MOD_DIR}") | ||
make_directory("${LIB_MOD_DIR}") | ||
endif() | ||
|
||
|
||
# Do the preprocessing | ||
fdict_fyppify( | ||
|
@@ -43,22 +37,21 @@ install( | |
# Finally define the fdict library | ||
add_library(${PROJECT_NAME} ${fdict_sources}) | ||
|
||
# Attach the headers to the target | ||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
POSITION_INDEPENDENT_CODE ON | ||
Fortran_MODULE_DIRECTORY "${LIB_MOD_DIR}" | ||
) | ||
|
||
# Install all modules (omitting the directory) | ||
install(DIRECTORY "${LIB_MOD_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") | ||
# TODO: Move to single module interface and move the other modules to subfolder | ||
# This is to avoid name-clashing (similar to how C projects structure their include) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you meen here? Currently all modules from fdict is exposed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The convention in C/C++ projects is to install only 1 header file per project with a unique name. In cases where multiple header files are needed (header only libraries for example), than all the header files are in a subdirectory with the unique name of the project. Otherwise when you install another project that has similar header file names, they will overwrite each other and become unusable. Same convention applies here. There is a potential of overlap with another project that uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. |
||
install(FILES | ||
${CMAKE_Fortran_MODULE_DIRECTORY}/dictionary.mod | ||
${CMAKE_Fortran_MODULE_DIRECTORY}/variable.mod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add quotation for paths with spaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See earlier disccussion |
||
${CMAKE_Fortran_MODULE_DIRECTORY}/fdict_types.mod | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
# Ensure that the target contains the headers/modules/include files | ||
# and that it gets exported with the Targets output | ||
target_include_directories(${PROJECT_NAME} | ||
INTERFACE | ||
$<BUILD_INTERFACE:"${LIB_MOD_DIR}"> | ||
$<INSTALL_INTERFACE:"${CMAKE_INSTALL_INCLUDEDIR}"> | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
) | ||
|
||
# Install the library targets | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add quotation, to ensure paths with spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested locally and the quotation does not appear to be necessary. In general I would avoid quotations where unnecessary (in this case the variable
CMAKE_CURRENT_BINARY_DIR
is already sanitized to be a string) because sometimes the quotations are taken to be literal (as you've seen here in the generator expression). My rule of thumb is to sanitize everything at theset()
,option()
level rather than where the variables are used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, this is something where CMake is horrible, it is hard to know why some of the expansions works seamlessly, and others are problematic... Hence my guarding was just to put quotation everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fully agree. This is a relic of the original cmake design, and although there are rumors that the lead devs are working on a more robust, non text-based interface for camke 4, these are here to stay :(.
I was doing the same thing until I had various things break down because of the quotation. I realized though that most cmake commands are designed to work on variables (e.g. the
if()
command), so I work on the assumption that most commands are designed and tested to work for unquoted formats, and just use the quotation when it is needed to enforce it.