What is the right place for FindXXX.cmake files for locally compiled libs?












16















I have a lib I installed by hand (to /usr/local) on a Linux system (Eigen3, by the way). There is a FindEigen3.cmake bundled with the lib but that is not installed anywhere by default.



There is /usr/share/cmake-x.y/Modules where CMake looks for additional modules, but putting these files there doesn't seem the way to do things. Is there an equivalent place under /usr/local that is also scanned by default? Or what is the standard way of creating custom library modules?



(Although the question isn't strictly connected to programming, I think library authors may also encounter the same question from the other side: where to put these files when installing manually.)










share|improve this question



























    16















    I have a lib I installed by hand (to /usr/local) on a Linux system (Eigen3, by the way). There is a FindEigen3.cmake bundled with the lib but that is not installed anywhere by default.



    There is /usr/share/cmake-x.y/Modules where CMake looks for additional modules, but putting these files there doesn't seem the way to do things. Is there an equivalent place under /usr/local that is also scanned by default? Or what is the standard way of creating custom library modules?



    (Although the question isn't strictly connected to programming, I think library authors may also encounter the same question from the other side: where to put these files when installing manually.)










    share|improve this question

























      16












      16








      16








      I have a lib I installed by hand (to /usr/local) on a Linux system (Eigen3, by the way). There is a FindEigen3.cmake bundled with the lib but that is not installed anywhere by default.



      There is /usr/share/cmake-x.y/Modules where CMake looks for additional modules, but putting these files there doesn't seem the way to do things. Is there an equivalent place under /usr/local that is also scanned by default? Or what is the standard way of creating custom library modules?



      (Although the question isn't strictly connected to programming, I think library authors may also encounter the same question from the other side: where to put these files when installing manually.)










      share|improve this question














      I have a lib I installed by hand (to /usr/local) on a Linux system (Eigen3, by the way). There is a FindEigen3.cmake bundled with the lib but that is not installed anywhere by default.



      There is /usr/share/cmake-x.y/Modules where CMake looks for additional modules, but putting these files there doesn't seem the way to do things. Is there an equivalent place under /usr/local that is also scanned by default? Or what is the standard way of creating custom library modules?



      (Although the question isn't strictly connected to programming, I think library authors may also encounter the same question from the other side: where to put these files when installing manually.)







      linux cmake






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 3 '11 at 11:02









      LataniusLatanius

      1,48121320




      1,48121320
























          3 Answers
          3






          active

          oldest

          votes


















          7














          See the comments in the CMake documentation for the "find_package" command:



          http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package



          It speaks of writing a "project-config" file, and where to install it, such that find_package(Eigen3) will work without having a FindEigen3.cmake find module... It is verbose, but the information is in there.



          See also user contributed wiki pages such as this one:



          https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file






          share|improve this answer


























          • although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

            – Latanius
            Apr 18 '11 at 5:15



















          4














          In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):



          set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  





          share|improve this answer

































            3














            You need to set the CMAKE_MODULE_PATH to include the directory that the FindEigen3.cmake file is in before calling find_package. I believe that:



            set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your path> )


            will do the trick, but I do not have a setup to test that available at the moment so you may have to massage that technique a bit.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5529186%2fwhat-is-the-right-place-for-findxxx-cmake-files-for-locally-compiled-libs%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              7














              See the comments in the CMake documentation for the "find_package" command:



              http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package



              It speaks of writing a "project-config" file, and where to install it, such that find_package(Eigen3) will work without having a FindEigen3.cmake find module... It is verbose, but the information is in there.



              See also user contributed wiki pages such as this one:



              https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file






              share|improve this answer


























              • although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

                – Latanius
                Apr 18 '11 at 5:15
















              7














              See the comments in the CMake documentation for the "find_package" command:



              http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package



              It speaks of writing a "project-config" file, and where to install it, such that find_package(Eigen3) will work without having a FindEigen3.cmake find module... It is verbose, but the information is in there.



              See also user contributed wiki pages such as this one:



              https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file






              share|improve this answer


























              • although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

                – Latanius
                Apr 18 '11 at 5:15














              7












              7








              7







              See the comments in the CMake documentation for the "find_package" command:



              http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package



              It speaks of writing a "project-config" file, and where to install it, such that find_package(Eigen3) will work without having a FindEigen3.cmake find module... It is verbose, but the information is in there.



              See also user contributed wiki pages such as this one:



              https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file






              share|improve this answer















              See the comments in the CMake documentation for the "find_package" command:



              http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package



              It speaks of writing a "project-config" file, and where to install it, such that find_package(Eigen3) will work without having a FindEigen3.cmake find module... It is verbose, but the information is in there.



              See also user contributed wiki pages such as this one:



              https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 18 '18 at 14:22









              ronen

              1,4951918




              1,4951918










              answered Apr 4 '11 at 14:19









              DLRdaveDLRdave

              10.3k23962




              10.3k23962













              • although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

                – Latanius
                Apr 18 '11 at 5:15



















              • although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

                – Latanius
                Apr 18 '11 at 5:15

















              although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

              – Latanius
              Apr 18 '11 at 5:15





              although I didn't have the time (in the last two weeks :P) to check this in action, this was what I was looking for, thanks!

              – Latanius
              Apr 18 '11 at 5:15













              4














              In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):



              set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  





              share|improve this answer






























                4














                In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):



                set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  





                share|improve this answer




























                  4












                  4








                  4







                  In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):



                  set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  





                  share|improve this answer















                  In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):



                  set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 22 '18 at 2:27









                  RAM

                  716517




                  716517










                  answered Apr 17 '11 at 10:45









                  beduinbeduin

                  5,33232222




                  5,33232222























                      3














                      You need to set the CMAKE_MODULE_PATH to include the directory that the FindEigen3.cmake file is in before calling find_package. I believe that:



                      set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your path> )


                      will do the trick, but I do not have a setup to test that available at the moment so you may have to massage that technique a bit.






                      share|improve this answer




























                        3














                        You need to set the CMAKE_MODULE_PATH to include the directory that the FindEigen3.cmake file is in before calling find_package. I believe that:



                        set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your path> )


                        will do the trick, but I do not have a setup to test that available at the moment so you may have to massage that technique a bit.






                        share|improve this answer


























                          3












                          3








                          3







                          You need to set the CMAKE_MODULE_PATH to include the directory that the FindEigen3.cmake file is in before calling find_package. I believe that:



                          set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your path> )


                          will do the trick, but I do not have a setup to test that available at the moment so you may have to massage that technique a bit.






                          share|improve this answer













                          You need to set the CMAKE_MODULE_PATH to include the directory that the FindEigen3.cmake file is in before calling find_package. I believe that:



                          set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your path> )


                          will do the trick, but I do not have a setup to test that available at the moment so you may have to massage that technique a bit.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 3 '11 at 23:36









                          ltcltc

                          2,3491923




                          2,3491923






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5529186%2fwhat-is-the-right-place-for-findxxx-cmake-files-for-locally-compiled-libs%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                              Alcedinidae

                              RAC Tourist Trophy