refine config.cmake and fix math macros