In root directory of the project you wish to build, run
> cmake
You’ll likely need a few option variables to get it right:
Option | Significance |
---|---|
CMAKE_INSTALL_PREFIX=/a/path |
Installation path is /a/path |
BUILD_SHARED_LIBS=ON |
Build shared (dynamic) libraries |
CMAKE_BUILD_TYPE=Debug |
Generate files with debug flags set |
CMAKE_C_COMPILER=icc |
Sets C Language compiler to icc |
CMAKE_CXX_FLAGS="-O3" |
Sets C++ compiler optimization level 3 |
CMAKE_PREFIX_PATH=/a/path |
Search for dependencies in /a/path |
Many more at: http://www.cmake.org/Wiki/CMake_Useful_Variables
CMake
configuration.¶Options can be given on the command line:
> cmake -DCMAKE INSTALL PREFIX=/usr/local .
Or given in a bash script:
#!/usr/bin/env bash
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=icpc \
/path/to/src
After configuration is complete, type
> make
Can usually build in parallel on multi-core machines, to build on 2 processors
> make -j2
If the project has a test suite,
> make test or > ctest
To install in prefix location (must have permissions)
> make install
ccmake
.CMake instructions go in CMakeLists.txt
file
For example, a typical project directory structure might have:
my_project/
├── CMakeLists.txt
├── src/
| ├── my_source_file_1.cc
| ├── my_source_file_2.cc
| └── CMakeLists.txt
└── test/
├── my_test_1.cc
├── my_test_2.cc
└── CMakeLists.txt
The top level CMakeLists.txt
would have the commands:
add_subdirectrory(src)
add_subdirectrory(test)
To create a compiled library:
add_library(library_name library_source_file_1.cc library_source_file_2.cc)
To create a compiled executable:
add_executable(executable_name executable_source_file_1.cc library_source_file_2.cc)
To add header file locations:
target_include_directories(library_or_executable_name /path/to/header_files)
To link against other libraries:
target_link_libraries(library_or_executable_name library_name_to_link_against)
set()
if()/endif()
, e.g.set(MY_BOOL_VAR ON)
if(MY_BOOL_VAR)
#Do something
else()
#Do something else
endif()
%%javascript
function hideElements(elements, start) {
for(var i = 0, length = elements.length; i < length;i++) {
if(i >= start) {
elements[i].style.display = "none";
}
}
}
var prompt_elements = document.getElementsByClassName("prompt");
hideElements(prompt_elements, 0)