[CMake] Writing find packages

Robert Dailey rcdailey.lists at gmail.com
Thu Sep 3 17:15:20 EDT 2015


How recent is this documentation?
http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries#Writing_find_modules

It seems rather old. What is the modern way of doing this? Below is my
find module, I'm not sure if I'm doing it "the right way":

# Try to find the vsvars32.bat file

if( MSVC_VERSION EQUAL 1900 )
    set( ENV_VAR_NUM 140 )
endif()

set( vscomntools $ENV{} )

find_file( VSVARS_FILE vsvars32.bat
    HINTS ENV "VS${ENV_VAR_NUM}COMNTOOLS"
)

include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( FindVSVars DEFAULT_MSG VSVARS_FILE )

mark_as_advanced( VSVARS_FILE )


More information about the CMake mailing list