cmake

CMake set_property command with generator expressions using multiple values

走远了吗. 提交于 2020-12-12 06:04:07
问题 I am using CMake v3.13.4 with the Visual Studio 2017 Win64 generator and I need to modify the command line options for the Visual Studio Librarian (for a CMake object library). To achieve that CMake offers the target property STATIC_LIBRARY_OPTIONS that can be set by the set_property and set_target_properties command. The documentation states that STATIC_LIBRARY_OPTIONS supports generator expressions: Contents of STATIC_LIBRARY_OPTIONS may use “generator expressions” with the syntax $<...> .

CMake set environment variable

痞子三分冷 提交于 2020-12-11 08:47:09
问题 According to the CMake documentation https://cmake.org/cmake/help/v3.3/command/set.html One can do set(ENV{<variable>} <value>) but this gives the result set(ENV{FOO} foo) message("variable is $ENV{FOO}") at configure time variable is foo But at Linux command echo $FOO the variable is not set. EDIT: Here's a partial solution to the problem, which was to set $PATH , so that a user has CMAKE_INSTALL_PREFIX listed first set(file_sh ${CMAKE_CURRENT_BINARY_DIR}/path.sh) set(path "${CMAKE_INSTALL

CMake set environment variable

核能气质少年 提交于 2020-12-11 08:47:06
问题 According to the CMake documentation https://cmake.org/cmake/help/v3.3/command/set.html One can do set(ENV{<variable>} <value>) but this gives the result set(ENV{FOO} foo) message("variable is $ENV{FOO}") at configure time variable is foo But at Linux command echo $FOO the variable is not set. EDIT: Here's a partial solution to the problem, which was to set $PATH , so that a user has CMAKE_INSTALL_PREFIX listed first set(file_sh ${CMAKE_CURRENT_BINARY_DIR}/path.sh) set(path "${CMAKE_INSTALL

How can I link CMake and SQLite without an external script?

杀马特。学长 韩版系。学妹 提交于 2020-12-08 07:16:05
问题 I have the following CMakeLists: cmake_minimum_required (VERSION 2.8.12.2) project (Tutorial) find_package (sqlite3) if (SQLITE3_FOUND) include_directories(${SQLITE3_INCLUDE_DIRS}) target_link_libraries (new ${SQLITE3_LIBRARIES}) endif (SQLITE3_FOUND) add_executable(Tutorial new.cpp) However, when I cmake, I get the following message: CMake Warning at CMakeLists.txt:3 (find_package): By not providing "Findsqlite3.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package

Where should cmake files be installed?

让人想犯罪 __ 提交于 2020-12-06 07:26:23
问题 Where should cmake files be installed? I currently have for the install targets cmake_minimum_required(VERSION 2.8.10) project(projectname) include(CMakePackageConfigHelpers) include(GNUInstallDirs) add_library(projectnameINTERFACE) target_include_directories(projectnameINTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectname> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/> ) configure_package_config_file(projectnameConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/projectnameConfig

Where should cmake files be installed?

独自空忆成欢 提交于 2020-12-06 07:24:11
问题 Where should cmake files be installed? I currently have for the install targets cmake_minimum_required(VERSION 2.8.10) project(projectname) include(CMakePackageConfigHelpers) include(GNUInstallDirs) add_library(projectnameINTERFACE) target_include_directories(projectnameINTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectname> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/> ) configure_package_config_file(projectnameConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/projectnameConfig

Setup CMake with SFML in VS2017

寵の児 提交于 2020-12-05 20:37:18
问题 Just like in CLion I want to use SFML with Visual Studio 2017, but I'm still learning cmake and I don't know the commands or the logic of how cmake works at all. I've just seen some posts and got this litle script. Note: I downloaded the latest version of sfml in the link provided, I just taked the extrated directory and put alongside CMakeLists.txt in my folder #sets up the minimum version of cmake cmake_minimum_required(VERSION 3.9) #how the project will be called project (space_impact)

Setup CMake with SFML in VS2017

对着背影说爱祢 提交于 2020-12-05 20:32:50
问题 Just like in CLion I want to use SFML with Visual Studio 2017, but I'm still learning cmake and I don't know the commands or the logic of how cmake works at all. I've just seen some posts and got this litle script. Note: I downloaded the latest version of sfml in the link provided, I just taked the extrated directory and put alongside CMakeLists.txt in my folder #sets up the minimum version of cmake cmake_minimum_required(VERSION 3.9) #how the project will be called project (space_impact)

cmake: check if file exists at build time rather than during cmake configuration

血红的双手。 提交于 2020-12-05 11:28:47
问题 I have a custom build command that needs to check if a certain file exists. I tried using IF(EXISTS "/the/file") ... ELSE() ... ENDIF() but that test is only evaluated one; when cmake is first run. I need it to perform the test every time a make is done. What's the method to check at make-time? Thanks. 回答1: You can use add_custom_command to invoke CMake itself in script mode by using the -P command line option. So your command would be something like: set(FileToCheck "/the/file") add_custom

cmake: check if file exists at build time rather than during cmake configuration

喜欢而已 提交于 2020-12-05 11:26:46
问题 I have a custom build command that needs to check if a certain file exists. I tried using IF(EXISTS "/the/file") ... ELSE() ... ENDIF() but that test is only evaluated one; when cmake is first run. I need it to perform the test every time a make is done. What's the method to check at make-time? Thanks. 回答1: You can use add_custom_command to invoke CMake itself in script mode by using the -P command line option. So your command would be something like: set(FileToCheck "/the/file") add_custom