sudo apt-get install build-essential wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz tar xf cmake-3.2.2.tar.gz cd cmake-3.2.2 ./configure make && make install
which cmake #/usr/local/bin/cmake cmake --version
or by apt-get -y install cmake
User defined cmake
FindXXX.cmake in CMAKE_MODULE_PATH
xxx-config.cmake in CMAKE_PREFIX_PATH
cmake default package
FindXXX.cmake
use find_package to find default package with name XXX
and cmake file C:\Program Files\CMake\share\cmake-3.10\Modules\FindXXX.cmake
use ${XXX_INCLUDE_DIRS} in include, and ${XXX_LIBRARIES} in libraries
# Name: <Name>Config.cmake or <lower name>-config.cmake # mysqlcppconn-config.cmake or MYSQLCPPCONNConfig.cmake # similar to OpenCVConfig.cmake
# Tips for MYSQLCPPCONN_ROOT_DIR # use "C:/Program Files/MySQL/Connector.C++ 1.1", otherwise cmake-gui can not auto find include and library
set(MYSQLCPPCONN_FOUND TRUE) # auto set(MYSQLCPPCONN_ROOT_DIR "C:/Program Files/MySQL/Connector.C++ 1.1")
find_path(MYSQLCPPCONN_INCLUDE_DIR NAMES cppconn/driver.h PATHS "${MYSQLCPPCONN_ROOT_DIR}/include") mark_as_advanced(MYSQLCPPCONN_INCLUDE_DIR) # show entry in cmake-gui
find_library(MYSQLCPPCONN_LIBRARY NAMES mysqlcppconn.lib PATHS "${MYSQLCPPCONN_ROOT_DIR}/lib/opt") mark_as_advanced(MYSQLCPPCONN_LIBRARY) # show entry in cmake-gui
# use xxx_INCLUDE_DIRS and xxx_LIBRARIES in CMakeLists.txt set(MYSQLCPPCONN_INCLUDE_DIRS ${MYSQLCPPCONN_INCLUDE_DIR} ) set(MYSQLCPPCONN_LIBRARIES ${MYSQLCPPCONN_LIBRARY} )
# cmake entry will be saved to build/CMakeCache.txt
/usr/bin/ld: /usr/local/lib/libdlib.a(test_for_odr_violations.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libdlib.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status