Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
c350cec9
Verified
Commit
c350cec9
authored
4 years ago
by
Marcus Asteborg
Committed by
Mark Harris
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmake - move all compiler feature detection to OpusConfig
Signed-off-by:
Mark Harris
<
mark.hsj@gmail.com
>
parent
d00d866e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+28
-35
28 additions, 35 deletions
CMakeLists.txt
cmake/OpusConfig.cmake
+10
-0
10 additions, 0 deletions
cmake/OpusConfig.cmake
cmake/OpusFunctions.cmake
+0
-8
0 additions, 8 deletions
cmake/OpusFunctions.cmake
with
38 additions
and
43 deletions
CMakeLists.txt
+
28
−
35
View file @
c350cec9
...
...
@@ -20,7 +20,6 @@ project(Opus LANGUAGES C VERSION ${PROJECT_VERSION})
include
(
OpusBuildtype
)
option
(
OPUS_BUILD_SHARED_LIBRARY
"Build shared library"
OFF
)
option
(
OPUS_STACK_PROTECTOR
"Use stack protection"
ON
)
option
(
OPUS_CUSTOM_MODES
"Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames"
OFF
)
option
(
OPUS_BUILD_PROGRAMS
"Build programs"
OFF
)
...
...
@@ -66,16 +65,14 @@ cmake_dependent_option(OPUS_NONTHREADSAFE_PSEUDOSTACK
cmake_dependent_option
(
OPUS_FAST_MATH
"Enable fast math"
ON
"OPUS_FLOAT_APPROX; OPUS_FAST_MATH"
"OPUS_FLOAT_APPROX; OPUS_FAST_MATH
; FAST_MATH_SUPPORTED
"
OFF
)
if
(
OPUS_FAST_MATH
)
if
(
MSVC
)
check_and_set_flag
(
FAST_MATH /fp:fast
)
else
()
check_and_set_flag
(
FAST_MATH -ffast-math
)
endif
()
endif
()
cmake_dependent_option
(
OPUS_STACK_PROTECTOR
"Use stack protection"
ON
"STACK_PROTECTOR_SUPPORTED"
OFF
)
if
(
OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OPUS_BUILD_FRAMEWORK
)
# Global flag to cause add_library() to create shared libraries if on.
...
...
@@ -88,23 +85,6 @@ if(OPUS_BUILD_TESTING OR BUILD_TESTING)
set
(
BUILD_TESTING ON
)
endif
()
if
(
OPUS_STACK_PROTECTOR
)
if
(
MSVC
)
# GC on by default on MSVC
check_and_set_flag
(
STACK_PROTECTOR /GS
)
else
()
check_and_set_flag
(
STACK_PROTECTOR -fstack-protector-strong
)
endif
()
else
()
if
(
MSVC
)
check_and_set_flag
(
STACK_PROTECTOR_DISABLED /GS-
)
if
(
STACK_PROTECTOR_DISABLED_SUPPORTED
)
set
(
STACK_PROTECTOR_SUPPORTED OFF
)
endif
()
else
()
set
(
STACK_PROTECTOR_SUPPORTED OFF
)
endif
()
endif
()
if
(
OPUS_CPU_X86 OR OPUS_CPU_X64
)
cmake_dependent_option
(
OPUS_X86_MAY_HAVE_SSE
"Does runtime check for SSE1 support"
...
...
@@ -175,7 +155,7 @@ set_package_properties(Git
"required to set up package version"
)
add_feature_info
(
OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY
"Build shared library"
)
add_feature_info
(
OPUS_STACK_PROTECTOR STACK_PROTECTOR
_SUPPORTED
"Use stack protection"
)
add_feature_info
(
OPUS_STACK_PROTECTOR
OPUS_
STACK_PROTECTOR
"Use stack protection"
)
add_feature_info
(
OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS
"Use variable length arrays for stack arrays"
)
add_feature_info
(
OPUS_USE_ALLOCA OPUS_USE_ALLOCA
...
...
@@ -194,7 +174,7 @@ add_feature_info(
"compile with the floating point API (for machines with float library)"
)
add_feature_info
(
OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX
"Enable floating point approximations (Ensure your platform supports IEEE 754 before enabling)"
)
add_feature_info
(
OPUS_FAST_MATH FAST_MATH
_SUPPORTED
"Enable fast math, (depending on OPUS_FLOAT_APPROX to be enabled)"
)
add_feature_info
(
OPUS_FAST_MATH
OPUS_
FAST_MATH
"Enable fast math, (depending on OPUS_FLOAT_APPROX to be enabled)"
)
add_feature_info
(
OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE
"install PkgConfig module"
)
add_feature_info
(
OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE
...
...
@@ -279,15 +259,29 @@ if(OPUS_CUSTOM_MODES)
target_compile_definitions
(
opus PRIVATE CUSTOM_MODES
)
endif
()
if
(
OPUS_FAST_MATH
)
if
(
MSVC
)
target_compile_options
(
opus PRIVATE /fp:fast
)
else
()
target_compile_options
(
opus PRIVATE -ffast-math
)
endif
()
endif
()
if
(
OPUS_STACK_PROTECTOR
)
if
(
MSVC
)
target_compile_options
(
opus PRIVATE /GS
)
else
()
target_compile_options
(
opus PRIVATE -fstack-protector-strong
)
endif
()
elseif
(
STACK_PROTECTOR_DISABLED_SUPPORTED
)
target_compile_options
(
opus PRIVATE /GS-
)
endif
()
if
(
BUILD_SHARED_LIBS
)
if
(
WIN32
)
target_compile_definitions
(
opus PRIVATE DLL_EXPORT
)
else
()
include
(
CheckCCompilerFlag
)
check_c_compiler_flag
(
-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY
)
if
(
COMPILER_HAS_HIDDEN_VISIBILITY
)
set_target_properties
(
opus PROPERTIES C_VISIBILITY_PRESET hidden
)
endif
()
elseif
(
HIDDEN_VISIBILITY_SUPPORTED
)
set_target_properties
(
opus PROPERTIES C_VISIBILITY_PRESET hidden
)
endif
()
endif
()
...
...
@@ -408,7 +402,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
endif
()
if
(
COMPILER_SUPPORT_NEON AND OPUS_USE_NEON
)
if
(
OPUS_MAY_HAVE_NEON
)
if
(
RUNTIME_CPU_CAPABILITY_DETECTION
)
message
(
STATUS
"OPUS_MAY_HAVE_NEON enabling runtime detection"
)
...
...
This diff is collapsed.
Click to expand it.
cmake/OpusConfig.cmake
+
10
−
0
View file @
c350cec9
...
...
@@ -66,3 +66,13 @@ elseif(OPUS_CPU_ARM)
endif
()
endif
()
endif
()
if
(
MSVC
)
check_flag
(
FAST_MATH /fp:fast
)
check_flag
(
STACK_PROTECTOR /GS
)
check_flag
(
STACK_PROTECTOR_DISABLED /GS-
)
else
()
check_flag
(
FAST_MATH -ffast-math
)
check_flag
(
STACK_PROTECTOR -fstack-protector-strong
)
check_flag
(
HIDDEN_VISIBILITY -fvisibility=hidden
)
endif
()
This diff is collapsed.
Click to expand it.
cmake/OpusFunctions.cmake
+
0
−
8
View file @
c350cec9
...
...
@@ -92,14 +92,6 @@ function(get_package_version PACKAGE_VERSION)
set
(
PACKAGE_VERSION 0 PARENT_SCOPE
)
endfunction
()
function
(
check_and_set_flag NAME FLAG
)
include
(
CheckCCompilerFlag
)
check_c_compiler_flag
(
${
FLAG
}
${
NAME
}
_SUPPORTED
)
if
(
${
NAME
}
_SUPPORTED
)
add_definitions
(
${
FLAG
}
)
endif
()
endfunction
()
function
(
check_flag NAME FLAG
)
include
(
CheckCCompilerFlag
)
check_c_compiler_flag
(
${
FLAG
}
${
NAME
}
_SUPPORTED
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment