Commit Graph

34 Commits

Author SHA1 Message Date
Stephen Kelly bd34963002 Refactor generation of shared library flags
CMAKE_SHARED_LIBRARY_<lang>_FLAGS has flags on various platforms for a
variety of purposes that are correlated with shared libraries but not
exclusive to them.  Refactor generation of these flags to use new
purpose-specific platform variables

  CMAKE_<lang>_COMPILE_OPTIONS_DLL
  CMAKE_<lang>_COMPILE_OPTIONS_PIC
  CMAKE_<lang>_COMPILE_OPTIONS_PIE

Activate the DLL flags specifically for shared libraries.  Add a new
POSITION_INDEPENDENT_CODE target property to activate PIC/PIE flags, and
default to true for shared libraries to preserve default behavior.
Initialize the new property from CMAKE_POSITION_INDEPENDENT_CODE to
allow easy global configuration in projects.

Although the default behavior is unchanged by this refactoring, the new
approach ignores CMAKE_SHARED_LIBRARY_<lang>_FLAGS completely.  We must
leave it set in case projects reference the value.  Furthermore, if a
project modifies CMAKE_SHARED_LIBRARY_<lang>_FLAGS it expects the new
value to be used.  Add policy CMP0018 to handle compatibility with
projects that modify this platform variable.

Add a PositionIndependentCode test on platforms where we can get
meaningful results.
2012-06-12 15:38:48 -04:00
Brad King 953257ca61 try_compile: Cleanup temporary directories (#13160)
Since commit 4fbdce2b (try_compile: Use random executable file name,
2012-02-13) a different <target>.dir is used for each try-compile.
Cleanup the directories as well as their content to avoid accumulating
leftover temporary directories.
2012-04-26 08:20:58 -04:00
Yury G. Kudryashov 43d60114a5 Run vim spellcheck on some files 2012-02-29 14:07:50 -05:00
Brad King 4fbdce2b79 try_compile: Use random executable file name (#12957)
Append a random number to the "cmTryCompileExec" file name to avoid
rapid creation and deletion of the same executable file name.  Some
filesystems lock executable files when they are created and cause
subsequent try-compile tests to fail arbitrarily.  Use a different
name each time to avoid conflict.
2012-02-16 10:13:50 -05:00
Alex Neundorf 31f43fdb5a Remove trailing whitespace
Alex
2011-09-15 16:20:33 +02:00
Brad King 182eb7c7ef Merge topic 'dev/strict-mode'
dd2f814 Merge branch 'dev/add_test-working-directory' into dev/strict-mode
949d32c Unwatch manual variables upon removal in cmake-gui
3939032 Unwatch manual variables upon removal in ccmake
8354413 Add method to unwatch a manual variable
8ed3c85 Give a better message for unused variables
729db48 Fix ArgumentExpansion test expected results
89c2544 Checking for a definition is a usage
5625dee Don't output to stderr in the GUI
ad25a96 Merge branch 'ImprovedDotSupport2' into dev/strict-mode
c128abe Merge branch 'AddCMAKE_CURRENT_LIST_DIR' into dev/strict-mode
9bcaff0 Merge branch 'cmake-guiRememberAdvancedCheckbox' into dev/strict-mode
544d0c3 Fix expected output for WarnUninitialized test
4e3bea4 Update expected messages to new format
8e8c9e4 Don't check at destruction for usage
668e005 Use cmake::IssueMessage for warnings
88cd4c1 Use 'CMake Warning' versus 'warning' for CDash
3c3b98d Initialize the class before setting warn flags
cf8b15a Ignore files under the CMakeFiles directory
fd50f06 Don't check for unused vars at configure time
447a04c Don't warn during configure when doing everything
b97ee21 Check for unused variables at the end of generate
c18c977 When checking for variables, specify a reason
3f1121f Use a long int since Line is a long as well
2507f93 Change the failure case string to 'Unexpected'
fe390a2 Add 'ArgumentExpansion' test
8dbb209 Wrong boolean value for CLI warnings
d4ee998 Hard-code the --no-warn-unused-cli flag
a267b99 Fix line lengths
82ed104 Flag that the directories have been set
5aa535b Add argument to arg parsing to not set directories
367e5c3 Revert "Revert "When calling CMake, set the args and the cache""
ab5d4e4 Revert "When calling CMake, set the args and the cache"
9b90040 When calling CMake, set the args and the cache
fe56002 Fix long lines for KWStyle
5d30cfc Set a watch on variables added through the gui
33c63b1 Add a method to put a watch for variables
535253f Initialize the warning variables earlier
cbb286c Fix the path detection to work for top-level
62be1f7 Initialize the usage stack earlier
c6e7fab Factor out the checks for unused variables
5e41ba8 When using the API, check for Add vs. Remove
dee1976 Fix typo in VariableUnusedViaUnset test
f231ce5 Remove old false positive avoidance code
a117e02 Revert "Add test for unused warnings at the end of scope"
2c82f2b Exempt CMAKE(CURRENT|PARENT)_LIST_FILE from usage
6d7d449 Ignore CLI warnings for ABI determination
7740a73 Only return local keys that are defined
bef3aee Use the API so that warnings can be tracked
05cb0f4 Check for unused variables in the dtor
91c4c99 Add test for unused warnings at the end of scope
ca90f67 Fix detection of unused variables when setting
f7438ca Add test for unused detection via setting it
995cfb0 Don't warn if the variable wasn't defined
aefc91d Add test for usage checks via unset
a8e97f8 Remove VarRemoved code since it's been superceded
59463ef Rework CheckVariableForUnused usage
f117423 Fix line lengths to be no more than 78
e49a935 Improve unused warning logic
e01e40c Mark ARGC, ARGV*, and ARGN as used
a17aff7 Ignore CMAKE_MATCH_* variables for usage
02a114d Add method to allow variables to be marked as used
a0b0d23 CMAKE_DO_TRY_COMPILE is no longer used
ae3eff3 Fix the path used for ignoring system warnings
056b441 Fix missing case for usage of a variable
980e048 Factor out checks for unused variables
83acb0a Remove now unused variables
3801463 Use built-ins for readability and maintainability
8b52015 Push the initialize and unused states when copying
439877f Be consistent with single and double quotes
4cf1706 Add documentation for check-system-vars
b74777f Fix the spelling of the flag for warn-unused-vars
b948120 Change logic of flag to turn off cli unused checks
f047a17 Add test for uninitialized variables
75bda38 Add tests for unused command line variables
300fc15 Fix detection of system files
d784e6a Run the unused variables check on the final pass
9efc057 VariableWatch is not available when bootstrapping
2e78224 Add a missing comma to the warning message
7499700 Add a flag to warn about system files
fff9f6d Rename flags again and use variablewatch for cli
786e269 Add warn-unused to the Qt interface
636e6c4 Default to marking things as used
4ff0340 Rename find-unused to warn-unused
d7999e9 Rename strict-mode to warn-uninitialized
e141bc9 Detect unused variables
d3e8eb5 Add flags to detect unused variables
f332e14 Complete strict-mode checks for uninitialized vars
52f9637 Add method to get the local scope variables
f794d58 Make --strict-mode option, and integrate with cmake-gui
48b5b85 Add a warning when variables are used uninitialized.
cd626ea For macros make sure the FilePath points to a valid pointer in the args.
2011-01-27 15:34:07 -05:00
Brad King dd2f81491e Merge branch 'dev/add_test-working-directory' into dev/strict-mode
Conflicts:
	Tests/CMakeLists.txt
2011-01-27 14:39:55 -05:00
Brad King 7f37eac6dd Merge topic 'outdir-CMAKE_USER_MAKE_RULES_OVERRIDE'
5792d3a Always place try_compile executables predictably (#11724)
a5300f1 Clarify CMAKE_USER_MAKE_RULES_OVERRIDE documentation (#11724)
2011-01-26 15:24:44 -05:00
Brad King 5ec9f6f609 Merge topic 'fix-try_compile-source-language-issue-11731'
699a725 Use shortest extension to verify try_compile language (#11731)
2011-01-26 15:22:27 -05:00
Brad King 41147fcf48 Merge topic 'improve-try_compile-error-messages'
1bee6b1 Improve try_compile and try_run error messages
2011-01-26 15:22:00 -05:00
Brad King 699a725584 Use shortest extension to verify try_compile language (#11731)
If the source-file form of try_compile is given a file name with
multiple '.' characters such as "a.b.c" use only the shortest extension
to check the language.  This is the expected behavior and is consistent
with normal language extension determination in the method
cmSourceFileLocation::UpdateExtension.
2011-01-20 09:02:57 -05:00
Brad King 1bee6b172b Improve try_compile and try_run error messages
Use IssueMessage to give the messages context and better formatting.
2011-01-20 08:58:49 -05:00
Brad King 5792d3a38a Always place try_compile executables predictably (#11724)
Set CMAKE_RUNTIME_OUTPUT_DIRECTORY explicitly in try_compile projects so
that the COPY_FILE feature knows where to look.  This makes the feature
robust against CMAKE_USER_MAKE_RULES_OVERRIDE files that set variables
like CMAKE_RUNTIME_OUTPUT_DIRECTORY or EXECUTABLE_OUTPUT_PATH.
2011-01-20 08:08:47 -05:00
Brad King 72ebd4ee12 Merge topic 'try_compile-RemoveFile'
097294e Fix try_compile RemoveFile anti-virus loop (#11503)
2010-12-16 14:00:28 -05:00
Brad King 2afb820352 Write full version into try_compile CMakeLists
Pass the full version to cmake_minimum_required(VERSION) in generated
CMake files for try_compile projects.  This tells CMake not to use any
backward compatibility behavior while processing code it generates.
2010-12-14 16:36:55 -05:00
Brad King 097294e667 Fix try_compile RemoveFile anti-virus loop (#11503)
Commit 3827991e (...fix...not being able to remove try compile code,
2008-03-26) introduced a loop of RemoveFile attempts to overcome
anti-virus locks on recently created try_compile executables.  Fix the
logic in this loop to work when the file is already missing.
2010-12-03 07:38:15 -05:00
Ben Boeckel a0b0d23f0c CMAKE_DO_TRY_COMPILE is no longer used 2010-09-14 17:51:43 -04:00
Brad King c8ea2705a7 Use same type in both cases of '?:' operator
Both possible result values need to be convertible to the same type.
Some compilers fail to recognize that they can construct std::string
from the empty string literal, so state it explicitly.
2010-06-29 10:01:59 -04:00
David Genest 295b5b60df Honor CMAKE_USER_MAKE_RULES_OVERRIDE in try_compile (#10902) 2010-06-29 08:29:41 -04:00
Brad King 172d503c61 Fix try_compile when file cannot be found
The try_compile() command's COPY_FILE option should not try to actually
copy the file if it cannot be found.  Some C runtime library's fopen
cannot handle an empty file name.
2009-10-28 11:24:08 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King 80c947b397 No /fast targets in try_compile project mode
The try_compile command builds the cmTryCompileExec executable using the
cmTryCompileExec/fast target with Makefile generators in order to save
time since dependencies are not needed.  However, in project mode the
command builds an entire source tree that may have dependencies.
Therefore we can use the /fast target approach only in one-source mode.
2009-08-04 14:37:46 -04:00
Bill Hoffman 9c2dcf4836 BUG: fix for #0009051 CMake does not pass CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET when running TRY_COMPILE 2009-05-19 11:25:28 -04:00
David Cole d74b75af09 ENH: Emit a little more information in the error message when the output file is not found during a core try compile. 2009-01-29 15:23:18 -05:00
David Cole 3df1535c80 STYLE: Emit filenames in try_compile error message to get more information from the Continuous dashboard test that is failing. 2009-01-27 11:35:36 -05:00
Bill Hoffman 69a961a6ba ENH: make sure numAttempts is incremented 2008-03-26 13:50:23 -04:00
Bill Hoffman 3827991e87 ENH: try to fix dashboard issue with not being able to remove try compile code 2008-03-26 13:14:16 -04:00
Brad King 16b32f9c9b BUG: Change generated try-compile projects to use cmake_minimum_required instead of cmake_policy to set the version now that CMP0000 requires it. 2008-03-19 15:44:56 -04:00
Brad King 1d23ea1a2d BUG: Generated try-compile CMakeLists.txt file should call cmake_policy with the current version of CMake, not just 2.6. 2008-03-07 08:53:22 -05:00
Bill Hoffman ff445e3fd0 ENH: make sure policy is set in generated cmakelist files 2008-03-06 15:20:39 -05:00
Bill Hoffman 3944e268f4 ENH: for try compile do not put the rules to rebuild the project with cmake inside it. This has caused infinite loops of builds in some cases, and it is just a waste of time anyway. 2007-12-06 09:56:02 -05:00
Alexander Neundorf 74750610cf ENH: determine typesize by compiling a file and reading strings from the compiled output.
Tested with various gcc, XCode, MSVC7, sdcc
For OSX when doing TRY_COMPILE() CMAKE_OSX_ARCHITECTURES is used, if there are different results an error is generated. CMAKE_OSX_ARCHITECTURES can be overwritten for the TRY_COMPILES with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES.

Alex
2007-06-04 17:08:46 -04:00
Alexander Neundorf 7147c3e1cc ENH: add COPY_FILE argument to TRY_COMPILE, so the compiled executable can
be used e.g. for getting strings out of it.

Alex
2007-05-24 12:06:59 -04:00
Alexander Neundorf 7d7aba292c ENH: add two simple tests for TRY_RUN()
STYLE: create a new base class cmCoreTryCompile, from which
cmTryCompileCommand and cmTryRunCommand are derived, so there are no public
static functions with lots of arguments anymore

Alex
2007-05-24 11:27:51 -04:00