diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-18 01:31:55 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-24 21:53:50 +0100 |
commit | 15cb4261665bab4ef02a5b1b9db48b9477c9b87a (patch) | |
tree | d0c40a45afa19fff26ce1eb5bb703e18a9acdd4a /cmake | |
parent | 0d347c2b2e69aa09b079f6daaa00007fef4fe52f (diff) |
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/ModulePackage.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 1e49503a..b963e0de 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -1,8 +1,17 @@ | |||
1 | option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON) | 1 | option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON) |
2 | option(ENABLE_STATIC "Build static libraries for all modules" ON) | 2 | option(ENABLE_STATIC "Build static libraries for all modules" ON) |
3 | option(COMPILE_AS_CXX "Compile all C code as C++ code" OFF) | ||
3 | 4 | ||
4 | find_package(PkgConfig REQUIRED) | 5 | find_package(PkgConfig REQUIRED) |
5 | 6 | ||
7 | function(add_c_executable exec) | ||
8 | if(COMPILE_AS_CXX) | ||
9 | set_source_files_properties(${ARGN} PROPERTIES LANGUAGE CXX) | ||
10 | endif() | ||
11 | |||
12 | add_executable(${exec} ${ARGN}) | ||
13 | endfunction() | ||
14 | |||
6 | function(pkg_use_module mod) | 15 | function(pkg_use_module mod) |
7 | pkg_search_module(${mod} ${ARGN}) | 16 | pkg_search_module(${mod} ${ARGN}) |
8 | if(${mod}_FOUND) | 17 | if(${mod}_FOUND) |
@@ -13,6 +22,10 @@ function(pkg_use_module mod) | |||
13 | endfunction() | 22 | endfunction() |
14 | 23 | ||
15 | function(add_module lib) | 24 | function(add_module lib) |
25 | if(COMPILE_AS_CXX) | ||
26 | set_source_files_properties(${ARGN} PROPERTIES LANGUAGE CXX) | ||
27 | endif() | ||
28 | |||
16 | if(ENABLE_SHARED) | 29 | if(ENABLE_SHARED) |
17 | add_library(${lib}_shared SHARED ${ARGN}) | 30 | add_library(${lib}_shared SHARED ${ARGN}) |
18 | set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib}) | 31 | set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib}) |