diff --git a/.travis.yml b/.travis.yml index c1801871..56425402 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: xenial language: cpp compiler: gcc os: @@ -8,15 +9,12 @@ before_install: install: - echo $TRAVIS_OS_NAME - - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo apt-get update -qq - - sudo apt-get install -qq g++-4.8 - - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 - - sudo apt-get install -qq cmake - sudo apt-get install -qq ccache script: - echo $TRAVIS_OS_NAME + - cmake --version - git --version - python --version # test fips command itself diff --git a/README.md b/README.md index 4dd33a7e..ededad9e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,20 @@ http://floooh.github.io/fips/getstarted.html ### Public Service Announcements +- **08-Feb-2019**: + - **internal cmake script cleanup:** fips is now creating "empty" targets in the + ```fips_begin_*()``` calls and uses modern (post 3.0) commands to add + source files, dependencies and options to the targets (previously those + were gathered in custom variables, and creating the actual targets happend + in the ```fips_end_*()``` functions). This simplifies the fips cmake + scripts a lot, and it allows better mixing of native cmake commands with + fips commands (e.g. you can now use commands which modify cmake target + properties **inside** the fips begin/end blocks, previously such + commands had to be added *after* the ```fips_end_*```. Unfortunately the + changes break the Oryol unit testing cmake macros (which depend on internal + implementation details, which obviously is a bit naughty), so you need + to update fips and Oryol at the same time. + - **20-Jan-2019**: - NaCl and UWP support have been removed (both haven't been maintained for a very long time) - remove the builtin unittest support, this was hardwired to UnitTest++ and should diff --git a/cmake/fips.cmake b/cmake/fips.cmake index 8c07c51d..001123df 100644 --- a/cmake/fips.cmake +++ b/cmake/fips.cmake @@ -15,9 +15,7 @@ get_filename_component(FIPS_BUILD_DIR "${FIPS_ROOT_DIR}/../fips-build" ABSOLUTE) include(CMakeParseArguments) include("${FIPS_ROOT_DIR}/cmake/fips_private.cmake") -include("${FIPS_ROOT_DIR}/cmake/fips_windows.cmake") -include("${FIPS_ROOT_DIR}/cmake/fips_android.cmake") -include("${FIPS_ROOT_DIR}/cmake/fips_osx.cmake") +include("${FIPS_ROOT_DIR}/cmake/fips_platform.cmake") include("${FIPS_ROOT_DIR}/cmake/fips_generators.cmake") #------------------------------------------------------------------------------- @@ -37,7 +35,6 @@ option(FIPS_AUTO_IMPORT "Automatically include all modules from imports" ON) option(FIPS_CLANG_ADDRESS_SANITIZER "Enable clang address sanitizer" OFF) option(FIPS_CLANG_SAVE_OPTIMIZATION_RECORD "Enable clang -fsave-optimization-record option" OFF) - #------------------------------------------------------------------------------- # fips_setup() # Performs one-time initialization of the build system. Must be called @@ -241,77 +238,57 @@ macro(fips_project proj) endmacro() #------------------------------------------------------------------------------- -# fips_begin_module(module) -# Begin defining an fips module. +# fips_begin_lib(name) +# Begin defining a static link library # -macro(fips_begin_module name) - set(name ${name}) +macro(fips_begin_lib target) if (FIPS_CMAKE_VERBOSE) - message("Module: name=" ${name}) + message("Library: name=" ${target}) endif() - fips_reset(${name}) + fips_reset(${target}) + + # add library target + add_library(${CurTargetName} STATIC) + fips_apply_target_group(${CurTargetName}) endmacro() #------------------------------------------------------------------------------- -# fips_end_module(module) -# End defining an fips module, the interesting stuff happens here. +# fips_end_library(name) +# End defining a static link library. # -macro(fips_end_module) - - # add library target - add_library(${CurTargetName} ${CurSources}) - fips_apply_target_group(${CurTargetName}) - - # set platform- and target-specific compiler options - fips_vs_apply_options(${CurTargetName}) - - # add dependencies - fips_resolve_dependencies(${CurTargetName}) +macro(fips_end_lib) # handle generators (post-target) fips_handle_generators(${CurTargetName}) # track some target properties in YAML files - fips_addto_targets_list(${CurTargetName} "module") + fips_addto_targets_list(${CurTargetName} "lib") fips_addto_headerdirs_list(${CurTargetName}) fips_addto_defines_list(${CurTargetName}) + + set(CurTargetName) endmacro() #------------------------------------------------------------------------------- -# fips_begin_lib(name) -# Begin defining a static link library +# fips_begin_module(module) +# Begin defining an fips module. # -macro(fips_begin_lib name) - set(name ${name}) - if (FIPS_CMAKE_VERBOSE) - message("Library: name=" ${name}) - endif() - fips_reset(${name}) +# FIXME: modules and libs are now exactly the same, fips_begin_module +# should be phased out. +# +macro(fips_begin_module target) + fips_begin_lib(${target}) endmacro() #------------------------------------------------------------------------------- -# fips_end_library(name) -# End defining a static link library. +# fips_end_module(module) +# End defining an fips module, the interesting stuff happens here. # -macro(fips_end_lib) - - # add library target - add_library(${CurTargetName} ${CurSources}) - fips_apply_target_group(${CurTargetName}) - - # set platform- and target-specific compiler options - fips_vs_apply_options(${CurTargetName}) - - # add dependencies - fips_resolve_dependencies(${CurTargetName}) - - # handle generators (post-target) - fips_handle_generators(${CurTargetName}) - - # track some target properties in YAML files - fips_addto_targets_list(${CurTargetName} "lib") - fips_addto_headerdirs_list(${CurTargetName}) - fips_addto_defines_list(${CurTargetName}) +# FIXME: modules and libs are now exactly the same, fips_begin_module +# should be phased out. +# +macro(fips_end_module) + fips_end_lib() endmacro() #------------------------------------------------------------------------------- @@ -319,13 +296,50 @@ endmacro() # Begin an fips command line app. # Type can be "windowed" or "cmdline", default is "cmdline". # -macro(fips_begin_app name type) +macro(fips_begin_app target type) if (${type} STREQUAL "windowed" OR ${type} STREQUAL "cmdline") - fips_reset(${name}) - set(CurAppType ${type}) if (FIPS_CMAKE_VERBOSE) - message("App: name=" ${CurTargetName} " type=" ${CurAppType}) + message("App: target=" ${target} " type=" ${type}) endif() + fips_reset(${target}) + if (${type} STREQUAL "windowed") + if (FIPS_OSX) + add_executable(${CurTargetName} MACOSX_BUNDLE) + fips_osx_add_target_properties(${CurTargetName}) + fips_copy_osx_dylib_files(${CurTargetName} 1) + elseif (FIPS_WIN32 OR FIPS_WIN64) + add_executable(${CurTargetName} WIN32) + elseif (FIPS_ANDROID) + add_library(${CurTargetName} SHARED) + else() + add_executable(${CurTargetName}) + endif() + else() + if (FIPS_ANDROID) + add_library(${CurTargetName} SHARED) + else() + add_executable(${CurTargetName}) + endif() + if (FIPS_OSX) + fips_copy_osx_dylib_files(${CurTargetName} 0) + endif() + endif() + + # add standard frameworks and libs + if (FIPS_OSX) + fips_frameworks_osx(${FIPS_OSX_STANDARD_FRAMEWORKS}) + endif() + + # set the right IDE group + fips_apply_target_group(${CurTargetName}) + + # FIPS_APP_WINDOWED or FIPS_APP_CMDLINE defines + fips_apply_executable_type_defines(${CurTargetName} ${type}) + + # setup executable output directory and postfixes (_debug, etc...) + fips_config_output_directory(${CurTargetName}) + fips_config_postfixes_for_exe(${CurTargetName}) + else() message(FATAL_ERROR "type must be \"windowed\" or \"cmdline\"!") endif() @@ -337,48 +351,6 @@ endmacro() # macro(fips_end_app) - # add standard frameworks and libs - if (FIPS_OSX) - fips_frameworks_osx(${FIPS_OSX_STANDARD_FRAMEWORKS}) - endif() - - if (NOT CurSources) - message(FATAL_ERROR "No sources in target: ${CurTargetName} !!!") - endif() - - # add executable target - if (${CurAppType} STREQUAL "windowed") - # a windowed application - if (FIPS_OSX) - add_executable(${CurTargetName} MACOSX_BUNDLE ${CurSources}) - fips_osx_add_target_properties(${CurTargetName}) - fips_copy_osx_dylib_files(${CurTargetName} 1) - elseif (FIPS_WIN32 OR FIPS_WIN64) - add_executable(${CurTargetName} WIN32 ${CurSources}) - elseif (FIPS_ANDROID) - add_library(${CurTargetName} SHARED ${CurSources}) - else() - add_executable(${CurTargetName} ${CurSources}) - endif() - else() - # a command line application - if (FIPS_ANDROID) - add_library(${CurTargetName} SHARED ${CurSources}) - else() - add_executable(${CurTargetName} ${CurSources}) - endif() - if (FIPS_OSX) - fips_copy_osx_dylib_files(${CurTargetName} 0) - endif() - endif() - fips_apply_target_group(${CurTargetName}) - - # set platform- and target-specific compiler options - fips_vs_apply_options(${CurTargetName}) - - # FIPS_APP_WINDOWED or FIPS_APP_CMDLINE defines - fips_apply_executable_type_defines(${CurTargetName} ${CurAppType}) - # android specific stuff if (FIPS_ANDROID) fips_android_postbuildstep(${CurTargetName}) @@ -387,65 +359,53 @@ macro(fips_end_app) # handle generators (post-target) fips_handle_generators(${CurTargetName}) - # add dependencies - fips_resolve_dependencies(${CurTargetName}) - - # setup executable output directory and postfixes (_debug, etc...) - fips_config_output_directory(${CurTargetName}) - fips_config_postfixes_for_exe(${CurTargetName}) - # track some target properties in YAML files fips_addto_targets_list(${CurTargetName} "app") fips_addto_headerdirs_list(${CurTargetName}) fips_addto_defines_list(${CurTargetName}) + + set(CurTargetName) endmacro() #------------------------------------------------------------------------------- # fips_begin_sharedlib(name) # Begin a fips shared library. # -macro(fips_begin_sharedlib name) - fips_reset(${name}) +macro(fips_begin_sharedlib target) if (FIPS_CMAKE_VERBOSE) - message("Shared Lib: name=" ${CurTargetName}) + message("Shared Lib: target=" ${target}) endif() -endmacro() - -#------------------------------------------------------------------------------- -# fips_end_sharedlib() -# End defining a shared library. -# -macro(fips_end_sharedlib) + fips_reset(${target}) + + # add shared lib target + add_library(${CurTargetName} SHARED) + fips_apply_target_group(${CurTargetName}) # add standard frameworks and libs if (FIPS_OSX) fips_frameworks_osx(${FIPS_OSX_STANDARD_FRAMEWORKS}) endif() - if (NOT CurSources) - message(FATAL_ERROR "No sources in target: ${CurTargetName} !!!") - endif() + # setup executable output directory and postfixes (_debug, etc...) + fips_config_output_directory(${CurTargetName}) - # add shared lib target - add_library(${CurTargetName} SHARED ${CurSources}) - fips_apply_target_group(${CurTargetName}) +endmacro() - # set platform- and target-specific compiler options - fips_vs_apply_options(${CurTargetName}) +#------------------------------------------------------------------------------- +# fips_end_sharedlib() +# End defining a shared library. +# +macro(fips_end_sharedlib) # handle generators (post-target) fips_handle_generators(${CurTargetName}) - # add dependencies - fips_resolve_dependencies(${CurTargetName}) - - # setup executable output directory and postfixes (_debug, etc...) - fips_config_output_directory(${CurTargetName}) - # track some target properties in YAML files fips_addto_targets_list(${CurTargetName} "sharedlib") fips_addto_headerdirs_list(${CurTargetName}) fips_addto_defines_list(${CurTargetName}) + + set(CurTargetName) endmacro() #------------------------------------------------------------------------------- @@ -453,25 +413,27 @@ endmacro() # Add one or more dependencies to the current target. The dependencies # must be cmake build targets defined with fips_begin/end_module() # or fips_begin/end_lib(). Dependencies can also be added to fips modules -# or libs, they will then be resolved recursively in the app linking stage. +# or libs. # macro(fips_deps deps) - foreach(dep ${ARGV}) - list(APPEND CurDependencies ${dep}) - endforeach() + if (CurTargetName) + foreach(dep ${ARGV}) + target_link_libraries(${CurTargetName} ${dep}) + endforeach() + endif() endmacro() #------------------------------------------------------------------------------- # fips_libs(libs ...) # Add one or more static link library dependencies to the current target. -# The current target can also be a fips module or lib. Dependencies added -# with fips_libs() will be resolved recursively in the app linking stage -# (see fips_deps()). +# The current target can also be a fips module or lib. # macro(fips_libs libs) - foreach(lib ${ARGV}) - list(APPEND CurLinkLibs ${lib}) - endforeach() + if (CurTargetName) + foreach(lib ${ARGV}) + target_link_libraries(${CurTargetName} ${lib}) + endforeach() + endif() endmacro() #------------------------------------------------------------------------------- @@ -479,13 +441,13 @@ endmacro() # Add one or more static link library that are only used in debug mode. # This is sometimes necessary for precompiled visual studio libs (if they # use STL code). -# NOTE: libraries with fips_libs_debug() have no recursive dependency -# resolution. # macro(fips_libs_debug libs) - foreach(lib ${ARGV}) - list(APPEND CurLinkLibsDebug ${lib}) - endforeach() + if (CurTargetName) + foreach(lib ${ARGV}) + target_link_libraries(${CurTargetName} debug ${lib}) + endforeach() + endif() endmacro() #------------------------------------------------------------------------------- @@ -494,9 +456,11 @@ endmacro() # modes). # macro(fips_libs_release libs) - foreach(lib ${ARGV}) - list(APPEND CurLinkLibsRelease ${lib}) - endforeach() + if (CurTargetName) + foreach(lib ${ARGV}) + target_link_libraries(${CurTargetName} optimized ${lib}) + endforeach() + endif() endmacro() #------------------------------------------------------------------------------- @@ -679,28 +643,30 @@ endmacro() # is important, so define required targets BEFORE requiring generators. # macro(fips_generate) - set(options OUT_OF_SOURCE) - set(oneValueArgs FROM TYPE SOURCE HEADER ARGS REQUIRES) - set(multiValueArgs) - CMAKE_PARSE_ARGUMENTS(_fg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (_fg_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "fips_generate(): called with invalid args '${_fg_UNPARSED_ARGUMENTS}'") - endif() - if (NOT _fg_FROM) - message(FATAL_ERROR "fips_generate(): FROM arg required") - endif() - if (NOT _fg_SOURCE AND NOT _fg_HEADER) - # if both no SOURCE and no HEADER provided, set both - # to input file plus .cc / .h extension - get_filename_component(f_ext ${_fg_FROM} EXT) - string(REPLACE ${f_ext} ".cc" _fg_SOURCE ${_fg_FROM}) - string(REPLACE ${f_ext} ".h" _fg_HEADER ${_fg_FROM}) - endif() - if (_fg_REQUIRES) - fips_add_target_dependency(${_fg_REQUIRES}) + if (CurTargetName) + set(options OUT_OF_SOURCE) + set(oneValueArgs FROM TYPE SOURCE HEADER ARGS REQUIRES) + set(multiValueArgs) + CMAKE_PARSE_ARGUMENTS(_fg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (_fg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "fips_generate(): called with invalid args '${_fg_UNPARSED_ARGUMENTS}'") + endif() + if (NOT _fg_FROM) + message(FATAL_ERROR "fips_generate(): FROM arg required") + endif() + if (NOT _fg_SOURCE AND NOT _fg_HEADER) + # if both no SOURCE and no HEADER provided, set both + # to input file plus .cc / .h extension + get_filename_component(f_ext ${_fg_FROM} EXT) + string(REPLACE ${f_ext} ".cc" _fg_SOURCE ${_fg_FROM}) + string(REPLACE ${f_ext} ".h" _fg_HEADER ${_fg_FROM}) + endif() + if (_fg_REQUIRES) + fips_add_generator_dependency(${_fg_REQUIRES}) + endif() + fips_add_file("${_fg_FROM}") + fips_add_generator(${CurTargetName} "${_fg_TYPE}" ${_fg_OUT_OF_SOURCE} "${_fg_FROM}" "${_fg_SOURCE}" "${_fg_HEADER}" "${_fg_ARGS}") endif() - fips_add_file("${_fg_FROM}") - fips_add_generator(${CurTargetName} "${_fg_TYPE}" ${_fg_OUT_OF_SOURCE} "${_fg_FROM}" "${_fg_SOURCE}" "${_fg_HEADER}" "${_fg_ARGS}") endmacro() #------------------------------------------------------------------------------- diff --git a/cmake/fips_android.cmake b/cmake/fips_android.cmake deleted file mode 100644 index e6866e0f..00000000 --- a/cmake/fips_android.cmake +++ /dev/null @@ -1,17 +0,0 @@ -#------------------------------------------------------------------------------- -# fips_android.cmake -# Helper functions for building and deploying Android apps. -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# fips_android_postbuildstep -# -macro(fips_android_postbuildstep target) - add_custom_command(TARGET ${target} POST_BUILD - COMMAND python ${FIPS_ROOT_DIR}/tools/android-create-apk.py - --path ${CMAKE_CURRENT_BINARY_DIR} - --name ${target} - --package org.fips.${target} - --deploy ${FIPS_DEPLOY_DIR}/${FIPS_PROJECT_NAME}/${FIPS_CONFIG}) -endmacro() - diff --git a/cmake/fips_generators.cmake b/cmake/fips_generators.cmake index c66f7e57..c234e31c 100644 --- a/cmake/fips_generators.cmake +++ b/cmake/fips_generators.cmake @@ -31,6 +31,24 @@ # generated source files. # +#------------------------------------------------------------------------------- +# fips_add_generator_dependency(target...) +# Add one or more dependencies to the current generator target. The dependencies +# must be cmake build targets defined with fips_begin*/fips_end*(). +# Used to define a build order required when, for example, building tools to +# use during compilation of the current target. +# +macro(fips_add_generator_dependency targets) + foreach(target ${ARGV}) + if (TARGET ${target}) + list(APPEND CurGeneratorDependencies ${target}) + endif() + endforeach() + if (CurGeneratorDependencies) + list(REMOVE_DUPLICATES CurGeneratorDependencies) + endif() +endmacro() + #------------------------------------------------------------------------------- # fips_begin_gen(target) # @@ -47,7 +65,7 @@ endmacro() # Add a code generator item to the current target. # macro(fips_add_generator target in_generator in_outofsource in_file out_src out_hdr args) - if (FipsAddFilesEnabled) + if (CurTargetName) get_filename_component(f_abs ${CurDir}${in_file} ABSOLUTE) get_filename_component(f_dir ${f_abs} PATH) if ("${in_generator}" STREQUAL "") @@ -66,7 +84,7 @@ macro(fips_add_generator target in_generator in_outofsource in_file out_src out_ else() set(out_src_abs "${f_dir}/${out_src}") endif() - list(APPEND CurSources ${out_src_abs}) + target_sources(${CurTargetName} PRIVATE ${out_src_abs}) source_group("${CurGroup}\\gen" FILES ${out_src_abs}) set(yml_content "${yml_content} out_src: '${out_src_abs}'\n") if (NOT EXISTS ${out_src_abs}) @@ -81,7 +99,7 @@ macro(fips_add_generator target in_generator in_outofsource in_file out_src out_ else() set(out_hdr_abs "${f_dir}/${out_hdr}") endif() - list(APPEND CurSources ${out_hdr_abs}) + target_sources(${CurTargetName} PRIVATE ${out_hdr_abs}) source_group("${CurGroup}\\gen" FILES ${out_hdr_abs}) set(yml_content "${yml_content} out_hdr: '${out_hdr_abs}'\n") if (NOT EXISTS ${out_hdr_abs}) @@ -108,7 +126,7 @@ macro(fips_add_generator target in_generator in_outofsource in_file out_src out_ endmacro() #------------------------------------------------------------------------------- -# fips_handle_py_files_posttarget(target pyFiles) +# fips_handle_generators(target) # Create custom target for .py generator files. # macro(fips_handle_generators target) @@ -117,15 +135,15 @@ macro(fips_handle_generators target) add_custom_target(ALL_GENERATE COMMAND ${PYTHON} ${CMAKE_BINARY_DIR}/fips-gen.py ${CMAKE_BINARY_DIR}/fips_codegen.yml WORKING_DIRECTORY ${FIPS_PROJECT_DIR}) - if (CurTargetDependencies) - add_dependencies(ALL_GENERATE ${CurTargetDependencies}) + if (CurGeneratorDependencies) + add_dependencies(ALL_GENERATE ${CurGeneratorDependencies}) endif() endif() add_dependencies(${target} ALL_GENERATE) endif() - if (CurTargetDependencies) - add_dependencies(${target} ${CurTargetDependencies}) - unset(CurTargetDependencies) + if (CurGeneratorDependencies) + add_dependencies(${target} ${CurGeneratorDependencies}) + unset(CurGeneratorDependencies) endif() endmacro() diff --git a/cmake/fips_osx.cmake b/cmake/fips_platform.cmake similarity index 85% rename from cmake/fips_osx.cmake rename to cmake/fips_platform.cmake index e2ccc0d4..8b7cfdec 100644 --- a/cmake/fips_osx.cmake +++ b/cmake/fips_platform.cmake @@ -1,8 +1,40 @@ #------------------------------------------------------------------------------- -# fips_osx.cmake -# OSX/IOS specific cmake functions. -# FIXME: OSX framework resolution doesn't seem to work +# Target platform specific stuff +# + #------------------------------------------------------------------------------- +# fips_vs_warning_level(1..4) +# Set a module-specific warning level for Visual Studio, simply set this +# within a 'begin/end' pair. +# +macro(fips_vs_warning_level level) + if (FIPS_MSVC AND CurTargetName) + target_compile_options(${CurTargetName} PRIVATE "/W${level}") + endif() +endmacro() + +#------------------------------------------------------------------------------- +# fips_vs_disable_warning(warnings ...) +# Disable a specific vstudio warning +# +macro(fips_vs_disable_warnings warnings) + if (FIPS_MSVC AND CurTargetName) + foreach (warning ${ARGV}) + target_compile_options(${CurTargetName} PRIVATE "/wd${warning}") + endforeach() + endif() +endmacro() +#------------------------------------------------------------------------------- +# fips_android_postbuildstep +# +macro(fips_android_postbuildstep target) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND python ${FIPS_ROOT_DIR}/tools/android-create-apk.py + --path ${CMAKE_CURRENT_BINARY_DIR} + --name ${target} + --package org.fips.${target} + --deploy ${FIPS_DEPLOY_DIR}/${FIPS_PROJECT_NAME}/${FIPS_CONFIG}) +endmacro() #------------------------------------------------------------------------------- # fips_frameworks_osx(frameworks ...) @@ -10,9 +42,14 @@ # current target. # macro(fips_frameworks_osx frameworks) - foreach (fw ${ARGV}) - list(APPEND CurFrameworks ${fw}) - endforeach() + if (FIPS_OSX AND CurTargetName) + foreach (fw ${ARGV}) + unset(found_framework CACHE) + find_library(found_framework ${fw}) + target_link_libraries(${CurTargetName} ${found_framework}) + unset(found_framework CACHE) + endforeach() + endif() endmacro() #------------------------------------------------------------------------------- @@ -183,4 +220,3 @@ macro(fips_osx_add_target_properties target) endmacro() - diff --git a/cmake/fips_private.cmake b/cmake/fips_private.cmake index 0fa9ad66..710f07e3 100644 --- a/cmake/fips_private.cmake +++ b/cmake/fips_private.cmake @@ -10,16 +10,6 @@ macro(fips_reset target) set(CurDir) set(CurGroup "") - set(CurSources) - set(CurDependencies) - set(CurLinkLibs) - set(CurLinkLibsDebug) - set(CurLinkLibsRelease) - set(CurFrameworks) - set(CurAppType) - set(CurImgFiles) - set(CurCompileFlags "") - set(FipsAddFilesEnabled 1) set(CurTargetName ${target}) set(FIPS_OSX_PLIST_PATH) endmacro() @@ -44,33 +34,6 @@ macro(fips_setup_link_directories) endif() endmacro() -#------------------------------------------------------------------------------- -# fips_resolve_dependencies(target) -# Add all required dependencies to a target -# -macro(fips_resolve_dependencies target) - if (CurDependencies) - target_link_libraries(${CurTargetName} ${CurDependencies}) - endif() - if (CurLinkLibs) - target_link_libraries(${CurTargetName} ${CurLinkLibs}) - endif() - foreach (lib_debug ${CurLinkLibsDebug}) - target_link_libraries(${target} debug ${lib_debug}) - endforeach() - foreach (lib_release ${CurLinkLibsRelease}) - target_link_libraries(${target} optimized ${lib_release}) - endforeach() - if (FIPS_OSX) - foreach (fw ${CurFrameworks}) - unset(found_framework CACHE) - find_library(found_framework ${fw}) - target_link_libraries(${target} ${found_framework}) - unset(found_framework CACHE) - endforeach() - endif() -endmacro() - #------------------------------------------------------------------------------- # fips_config_postfixes_for_exe(target) # Internal macro to set the executable extensions @@ -177,19 +140,19 @@ macro(fips_choose_config) if (FIPS_HOST_WINDOWS) if (CMAKE_CL_64) if (${CMAKE_BUILD_TYPE} AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") - set(FIPS_CONFIG "win64-vs2013-release") + set(FIPS_CONFIG "win64-vstudio-release") elseif (${CMAKE_BUILD_TYPE} AND ${CMAKE_BUILD_TYPE} STREQUAL "Profiling") - set (FIPS_CONFIG "win64-vs2013-profiling") + set (FIPS_CONFIG "win64-vstudio-profiling") else() - set (FIPS_CONFIG "win64-vs2013-debug") + set (FIPS_CONFIG "win64-vstudio-debug") endif() else() if (${CMAKE_BUILD_TYPE} AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") - set (FIPS_CONFIG "win32-vs2013-release") + set (FIPS_CONFIG "win32-vstudio-release") elseif (${CMAKE_BUILD_TYPE} AND ${CMAKE_BUILD_TYPE} STREQUAL "Profiling") - set (FIPS_CONFIG "win32-vs2013-profiling") + set (FIPS_CONFIG "win32-vstudio-profiling") else() - set (FIPS_CONFIG "win32-vs2013-debug") + set (FIPS_CONFIG "win32-vstudio-debug") endif() endif() elseif (FIPS_HOST_OSX) @@ -217,8 +180,7 @@ endmacro() # additional handling for code generation files. # macro(fips_add_file new_file) - - if (FipsAddFilesEnabled) + if (CurTargetName) # handle subdirectory if (CurDir) set(cur_file "${CurDir}${new_file}") @@ -232,23 +194,14 @@ macro(fips_add_file new_file) source_group("${CurGroup}" FILES ${cur_file}) if (FIPS_OSX) - # mark .m as .c file for older cmake versions (bug is fixed in cmake 3.1+) - if (${f_ext} STREQUAL ".m") - set_source_files_properties(${cur_file} PROPERTIES LANGUAGE C) - endif() # handle plist files special if (${f_ext} STREQUAL ".plist") set(FIPS_OSX_PLIST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${cur_file}") endif() endif() - # add to global tracker variables - list(APPEND CurSources ${cur_file}) - - # remove dups - if (CurSources) - list(REMOVE_DUPLICATES CurSources) - endif() + # add file to target + target_sources(${CurTargetName} PRIVATE ${cur_file}) endif() endmacro() @@ -274,24 +227,6 @@ macro(fips_dir_groups path files) endforeach() endmacro() -#------------------------------------------------------------------------------- -# fips_add_target_dependency(target...) -# Add one or more dependencies to the current target. The dependencies -# must be cmake build targets defined with fips_begin*/fips_end*(). -# Used to define a build order required when, for example, building tools to -# use during compilation of the current target. -# -macro(fips_add_target_dependency targets) - foreach(target ${ARGV}) - if (TARGET ${target}) - list(APPEND CurTargetDependencies ${target}) - endif() - endforeach() - if (CurTargetDependencies) - list(REMOVE_DUPLICATES CurTargetDependencies) - endif() -endmacro() - #------------------------------------------------------------------------------- # fips_apply_executable_type_defines(target [cmdline|windowed]) # Adds the define FIPS_APP_CMDLINE or FIPS_APP_WINDOWED to the current @@ -300,7 +235,7 @@ endmacro() # entry function. # macro(fips_apply_executable_type_defines target type) - if (${CurAppType} STREQUAL "windowed") + if (${type} STREQUAL "windowed") target_compile_definitions(${target} PRIVATE FIPS_APP_WINDOWED=1) else() target_compile_definitions(${target} PRIVATE FIPS_APP_CMDLINE=1) diff --git a/cmake/fips_windows.cmake b/cmake/fips_windows.cmake deleted file mode 100644 index cc2b05af..00000000 --- a/cmake/fips_windows.cmake +++ /dev/null @@ -1,39 +0,0 @@ -#------------------------------------------------------------------------------- -# fips_windows.cmake -# Windows/VStudio-specific helper functions -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# fips_vs_warning_level(1..4) -# Set a module-specific warning level for Visual Studio, simply set this -# within a 'begin/end' pair. -# -macro(fips_vs_warning_level level) - if (FIPS_MSVC) - set(CurCompileFlags "${CurCompileFlags} /W${level}") - endif() -endmacro() - -#------------------------------------------------------------------------------- -# fips_vs_disable_warning(warnings ...) -# Disable a specific vstudio warning -# -macro(fips_vs_disable_warnings warnings) - if (FIPS_MSVC) - foreach (warning ${ARGV}) - set(CurCompileFlags "${CurCompileFlags} /wd${warning}") - endforeach() - endif() -endmacro() - -#------------------------------------------------------------------------------- -# fips_vs_apply_options() -# Applies the module-specific options set between begin/end -# -macro(fips_vs_apply_options target) - if (FIPS_MSVC) - if (NOT ${CurCompileFlags} STREQUAL "") - set_target_properties(${target} PROPERTIES COMPILE_FLAGS ${CurCompileFlags}) - endif() - endif() -endmacro() diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt index 62295a48..c2cfe186 100644 --- a/templates/CMakeLists.txt +++ b/templates/CMakeLists.txt @@ -1,7 +1,7 @@ # # project: $project # -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) # include the fips main cmake file get_filename_component(FIPS_ROOT_DIR "../fips" ABSOLUTE)