fdict icon indicating copy to clipboard operation
fdict copied to clipboard

CMake install

Open PhilliposK opened this issue 1 year ago • 10 comments
trafficstars

Thank you zerothi, for making this awesome library. This is exactly what I need for a project. Unfortunately, I'm new to both Fortran and CMake. I've reviewed as much as I can on CMake for Windows, but I'm struggling to install and link this library to my VS Code project. Please could you outline what you mean by the normal CMake procedure?

Thanks again!

PhilliposK avatar Mar 26 '24 12:03 PhilliposK

I have never tried on windows, but would be happy to ensure it works on Win.

Are you using WSL, or pure Win?

The general cmake procedure would be:

cmake -Bbuild_dir -S.
cmake --build build_dir

or something similar.

I have no experience with coupling a CMake project into a VS Code?

zerothi avatar Mar 26 '24 12:03 zerothi

Thank you for the ultrafast reply. I'm on a pure Win system. Should I generate my own CMakeLists.txt file before using the following lines?

cmake -Bbuild_dir -S cmake --build build_dir

PhilliposK avatar Mar 26 '24 12:03 PhilliposK

no, cmake should be part of this directory, so checkout the repo, then issue the above commands. (remember the . in front of S

zerothi avatar Mar 26 '24 12:03 zerothi

(Typo) So, would I be correct in stating that I should

1.) download and extract the fdict library to my project, 2.) run cmake -Bbuild_dir -S. cmake --build build_dir

with no other changes?

Thanks again!

PhilliposK avatar Mar 26 '24 12:03 PhilliposK

well, ideally you should just install the library somewhere, how do you otherwise add dependencies in your VS Code project?

But the above will compile fdict in and you should find a libfdict.dll in your build_dir directory. If you want to install it somewhere, you should specify so with -DCMAKE_INSTALL_PREFIX

zerothi avatar Mar 26 '24 12:03 zerothi

I'll have another look into this. After installation, you mentioned linking via:

FDICT_PATH = /path/to/fdict/parent FDICT_LIBS = -L$(FDICT_PATH) -lfdict FDICT_INC = -I$(FDICT_PATH)

Would this be written in the main Fortran file?

PhilliposK avatar Mar 26 '24 13:03 PhilliposK

No, this is how to link against external dependencies. Have you ever tried to link another library into an executable? :-D

zerothi avatar Mar 26 '24 13:03 zerothi

This may be the first time I've had to do this.

PhilliposK avatar Mar 26 '24 14:03 PhilliposK

Ok, you should definitely read up on how to link libraries/depedencies against a small project.

I would advice you to play around with this on a smaller scale before going into dependencies as you are doing now.
I would highly suggest you to ask around your local department for members who knows about this stuff.

Here is a minimal description of libraries and how to link them (works the same for fortran). https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html

zerothi avatar Mar 26 '24 14:03 zerothi

Thanks for all the help zerothi!

PhilliposK avatar Mar 26 '24 14:03 PhilliposK