Code Monkey home page Code Monkey logo

learning-cmake's Introduction

learning-cmake

This is a simple CMake tutorial project which contains some different scenarios.

  • hello-world: Demo a simplest CMake project.
  • hello-world-clear: Separate the output files and src files.
  • hello-world-lib: Demo how to make a static/shared library.
  • hello-world-shared: Demo how to utilize external static/shared library.
  • curl: Demo how to use cmake with curl.
  • hello-module: Demo how to use cmake find module.
  • config-file: Demo how to work with config.h.
  • hunter-simple: Demo how to use hunter and gtest.
  • boost: Demo how to use boost library.

Build steps

  • cmake -H. -B_builds
  • cmake --build _builds

CMake based tools

  • hunter: CMake-driven cross-platform package manager for C++.
  • CLion: CMake based IDE.

Nice CMake Resources

learning-cmake's People

Contributors

akagi201 avatar bitdeli-chef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learning-cmake's Issues

你没有写cmake find rules

CMake Warning at src/CMakeLists.txt:8 (find_package):
  By not providing "Findcurl.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "curl", but
  CMake did not find one.

  Could not find a package configuration file provided by "curl" with any of
  the following names:

    curlConfig.cmake
    curl-config.cmake

  Add the installation prefix of "curl" to CMAKE_PREFIX_PATH or set
  "curl_DIR" to a directory containing one of the above files.  If "curl"
  provides a separate development package or SDK, be sure it has been
  installed.

ERROR

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
Please rectify the error in the file of config-file/CMakeLists.txt

关于对cmake编译同名静态库和动态库的解释的建议

你好!我在阅读cmake-practice的文档时,有关于编译出hello.so和hello.a的两个库的内容中,涉及到使用
SET_TARGET_PROPERTIES(hello PROPERTIES CLEAN_DIRECT_OUTPUT 1) SET_TARGET_PROPERTIES(hello_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
来防止库因同名而被删除的问题,但是个人(目前使用的cmake是3.10.2)经过一些尝试,在不使用以上语句的情况下也能成功编译出两个同名的库,有没有可能是版本更新后对此进行了优化导致的?或者请问我这样的尝试有什么不当之处吗?还请赐教


ADD_LIBRARY(hello SHARED ${LIBHELLO_SRC})

#[[
SET_TARGET_PROPERTIES(
    hello 
    PROPERTIES 
                CLEAN_DIRECT_OUTPUT 1            
)
]]

ADD_LIBRARY(hello_static STATIC ${LIBHELLO_SRC})

SET_TARGET_PROPERTIES(
    hello_static
    PROPERTIES 
                OUTPUT_NAME "hello"
)

图片

problem at find_library in hello-module

Hi,
After hours of trying to build to hello-module project, found that according to the documentation for find_library you need to have PATHS rather than PATH to define additional paths for searching for the libraries.

error

A error in line 3 in hello-module/cmake/FindHELLO.cmake.
An s is missing after PATH.

CMakeList.txt error in first practice in "CMake Practice.pdf"

/backup/t1/CMakeLists.txt

PROJECT (HELLO)
SET(SRC_LIST main.c)
MESSAGE(STATUS "This is BINARY dir " ${HELLO_BINARY_DIR})
MESSAGE(STATUS "This is SOURCE dir "${HELLO_SOURCE_DIR})
ADD_EXECUTABLE(hello SRC_LIST)

line 1: space after PROJECT is unnessary.
line 4: need no space before ${HELLO_SOURCE_DIR}, or there will be warning.
line 5: ${SRC_LIST} not SRC_LIST, or there will be an error.

[DOC Error] ADD_EXECUTABLE expects the source files not the variable name

Hi there,
When I try the first example in cmake-pratice, page 6, cmake complains cannot find source files.

-- This is BINARY dir
-- This is SOURCE dir
-- Configuring done
CMake Error at CMakeLists.txt:8 (add_executable):
  Cannot find source file:

    SRC_LIST

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: hello
CMake Error: Cannot determine link language for target "hello".

After I modified add_executable(hello SRC_LIST) to add_executable(hello ${SRC_LIST}), this issue had been solved. So here must be using variable name. Can you check and update it?

cmake version 3.5.1

Question

感觉对unset的行为有点困惑。

An option that the user can select. Can accept condition to control when option is available for user.

Usage:

mxnet_option(<option_variable> "doc string" [IF ])

function(mxnet_option variable description value)
set(__value ${value})
set(__condition "")
set(__varname "__value")
foreach(arg ${ARGN})
if(arg STREQUAL "IF" OR arg STREQUAL "if")
set(__varname "__condition")
else()
list(APPEND ${__varname} ${arg})
endif()
endforeach()
unset(__varname) ==========>这里为什么要unset() unset之后这个变量不是不起作用?
if("${__condition}" STREQUAL "")
set(__condition 2 GREATER 1)
endif()

if(${__condition})
if("${__value}" MATCHES ";")
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
elseif(DEFINED ${__value})
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
else()
option(${variable} "${description}" ${__value})
endif()
else()
unset(${variable} CACHE)
endif()
endfunction()

Mastering CMake edition

This is more of a question than an actual issue. May I ask which edition of "Mastering CMake" you have in this repository?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.