Created
August 26, 2019 15:27
-
-
Save okhlybov/f18fbe50be6e88fe379e07319bf87601 to your computer and use it in GitHub Desktop.
CMake script template to build milti-language C/C++/Fortran executable with PkgConfig support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CMake script template to build milti-language C/C++/Fortran executable with PkgConfig support. | |
| # Replace ? with appropriate contents below. | |
| # Set to the project name from which executable name will be deduced | |
| project(?) | |
| # Set to the space-separated list of C, C++ and Fortran sources which constitute the program | |
| set(PROJECT_SOURCES ?) | |
| # Set to the space-separated list of dependent PkgConfig modules | |
| set(PROJECT_PC_MODULES ?) | |
| ### No user-serviceable parts below | |
| cmake_minimum_required(VERSION 3.0) | |
| enable_language(Fortran) | |
| enable_language(C) | |
| enable_language(CXX) | |
| include_directories(.) | |
| find_package(PkgConfig REQUIRED) | |
| foreach(PC ${PROJECT_PC_MODULES}) | |
| pkg_check_modules(${PC} REQUIRED ${PC}) | |
| link_directories(${${PC}_LIBRARY_DIRS}) | |
| include_directories(${${PC}_INCLUDE_DIRS}) | |
| add_compile_options(${${PC}_CFLAGS_OTHER}) | |
| endforeach(PC) | |
| add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) | |
| foreach(PC ${PROJECT_PC_MODULES}) | |
| target_link_libraries(${PROJECT_NAME} ${${PC}_LDFLAGS_OTHER}) | |
| target_link_libraries(${PROJECT_NAME} ${${PC}_LIBRARIES}) | |
| endforeach(PC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment